#include "sterna.h"
#include <QSqlDatabase>
#include <QMessageBox>
#include <QSqlQuery>
#include <QSqlError>
#include <QPrinter>
#include <QPrintPreviewDialog>
#include <QPainter>
#include <QtCore/qmath.h>
#include <QLocale>
#include <QTimer>
#include "qhsguserform.h"
#include <QCryptographicHash>




// Priemnici , Fakturi Vlezni TIP = 20 
// artikli kako trgovska roba tn proizvodi tip = 24
// Povratnici 23
// Nalog 22
// Izjava 21
// Ispratnici , Fakturi Izlezni TIP = 40
// ProFakturi TIP = 60
// Nalozi TIP = 30 //dodava proizvod vo magacin
// Nalozi TIP = 31 //prazni artikli od magacin
// Naracki TIP = 80 //dodava naracki vo magacin



sterna::sterna(QWidget *parent, Qt::WFlags flags)
	: QMainWindow(parent, flags)
    ,m_pageWidth(0)
    ,m_pageHeight(0)
    ,m_pageWidthScale(0)
    ,m_pageHeightScale(0)
    ,m_mykomintenti(0)
    ,m_myartikli(0)
    ,m_left(0)
    ,m_myispratnici(0)
    ,m_mypriemnici(0)
	,m_mykalkulacija(0)
	,m_mypovratnica(0)
    ,m_myfaktura(0)
    ,m_myfakturavlezna(0)
    ,m_mybanki(0)
    ,m_myddv(0)
    ,m_myizvod(0)	
    ,m_mykasa(0)
    ,m_mykartici(0)
    ,m_mylager(0)
    ,m_myizvestai(0)
    ,m_myprofakturi(0)
	,m_selectedPrint(-1)
    ,m_mykomintenti_analitika(0)
	,m_myizjava(0)
	,m_dnevenpromet(0)
	,m_mynalog(0)
	,m_mynormativ(0)
	,m_analitikaArtikli(0)
	,m_analitikaKomintenti(0)
	,m_mynaracki(0)
    ,m_myLSearch(0)
	,m_pltm(0)
	,m_mysmetki(0)
	,m_myNivelacija(0)
	,m_myLagerProdavnica(0)
	,m_myCenovnik(0)
	,m_prodPovratnica(0)
	,m_etm(0)
	,m_prodsmetka(0)
	,m_prodNivelacija(0)
	,m_mykontenplan(0)
	,m_myFinNal(0)
	,m_finanalitikaKomintenti(0)
	,m_employe(0)
{
	ui.setupUi(this);

	moi_artikli = trUtf8("Артикли");
	moi_banki = trUtf8("Банки");
	moi_ddv = trUtf8("ДДВ");
	moi_faktura = trUtf8("Излезни Фактури");
    moi_fakturavlezna = trUtf8("Влезни Фактури");
	moi_ispratnici = trUtf8("Испратници");
	moi_izvod = trUtf8("Изводи");
	moi_komintenti = trUtf8("Коминтенти");
	moi_kasa = trUtf8("Каса");
	moi_kartici = trUtf8("Картици");
	moi_lagerlista = trUtf8("Лагер Листа");
    moi_LSearch = trUtf8("Пребарување по норматив");
    moi_pltm = trUtf8("Приемен лист во трговија на мало");
    moi_proPovratnica = trUtf8("Продавница-Повратница");
	moi_etm = trUtf8("Евиденција во трговија");
	moi_prodsmetka = trUtf8("Продавница-Сметки");
	moi_prodNivelacija = trUtf8("Продавница-Нивелација");
	moi_kontenplan = trUtf8("Контен План");
	moi_izvestai = trUtf8("Извештаи");
	moi_povratnica = trUtf8("Повратници");
	moi_priemnici = trUtf8("Приемници");
	moi_kalkulacija = trUtf8("Калкулација");
	moi_finnal = trUtf8("Фин. Налози");
	moi_finanalitikaKomintenti = trUtf8("Финансова Картица");

	moi_profakturi = trUtf8("Про-Фактури");
    moi_komintenti_analitika = trUtf8("Аналитика по Коминтент");
	moi_izjava = trUtf8("Изјава");
	moi_dnevenpromet = trUtf8("Дневен Промет");
	moi_nalog = trUtf8("Налог");
	moi_normativ = trUtf8("Норматив");
	moi_mynaracki = trUtf8("Нарачки");
	moi_analitikaArtikli = trUtf8("Аналитика Артикли");
	moi_analitikaKomintenti = trUtf8("Аналитика Коминтенти");
	moi_smetki = trUtf8("Листа на Сметки");
	moi_nivelacija = trUtf8("Листа на Нивелации");
	moi_lagerProdavnica = trUtf8("Продавница - Лагер Листа");
	moi_Cenovnik = trUtf8("Продавница - Ценовник");


	moi_firma_info1 = trUtf8("ОФИС и КО ДОО");
	moi_firma_info2 = trUtf8("ул.Св. Кирил и Методиј бр.50 - Скопје");
	moi_firma_tel = trUtf8("тел. +389 02/ 3121-057");
	moi_firma_email = trUtf8("е-маил: 0ffice@on.net.mk");
	moi_firma_web = ("http://www.officeandco.com.mk");
	moi_firma_banka1 = trUtf8("НЛБ. Тутунска Банка: 210-0523456501-43");
	moi_firma_banka2 = trUtf8("ПроКредит банка:  380-1028287001-37");
	moi_firma_edb = trUtf8("Даночен број  МК4030998346429");
	moi_logo = ":/sterna/Resources/ddv.png";
	moi_izjava1 = trUtf8("Изјавувам дека продавам артикли од домашно потекло кои ");
	moi_izjava2 = trUtf8("се во моја сопственост__________________________________");



	moi_nozici = ":/sterna/Resources/scissors.png";

	connectToDatabase();
	statusBar()->showMessage(tr("Aplikacija Sterna"));
	ui.actionPrinter->setEnabled(false);
	ui.actionPreview->setEnabled(false);
	showUserDialog();
	Singleton *st = Singleton::Instance();
	QStringList info = st->getUserInfo();
	if(info.size())
	{
		statusBar()->showMessage(tr("Aplikacija Sterna - ")+ info.at(3) + " "+ info.at(4));
	}
	else
	{
		statusBar()->showMessage(tr("Aplikacija Sterna"));
	}
}

sterna::~sterna()
{

}
void sterna::createDockWindows()
{
    dock = new QDockWidget(this);
    dock->setWindowTitle(tr("Navigate"));
    dock->setFixedWidth(210);
    dock->setFixedHeight(500);
    dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    m_left = new QLeft(dock);
	dock->setWidget(m_left);

	addDockWidget(Qt::LeftDockWidgetArea, dock);
	connect(m_left, SIGNAL(updatePrinterStatus(QWidget*)), this, SLOT(updatePrinterStat(QWidget*)));
}

void sterna::showUserDialog()
{
	QUserForm * uf = new QUserForm((QDialog*)this);
	uf->setModal(true);
	if(uf->exec() == QDialog::Accepted)
	{
		CHelperClass *chc = new CHelperClass(this);

		int stop = 0;	
		QString str = uf->ui.lineEdit_2->text();
		QByteArray hash = QCryptographicHash::hash(str.toUtf8(), QCryptographicHash::Md5);
		QString str_pass = QString(hash.toHex());
		QString str_user = uf->ui.lineEdit->text();
		QStringList info = chc->getVraboteniInfo(str_user, str_pass);
		if (info.size())
		{
			Singleton *s = Singleton::Instance();
			s->setUserInfo(info);
			if (info.at(9) == "9999")
			{
				ui.actionVraboteni->setVisible(true);
			} 
			else
			{
				ui.actionVraboteni->setVisible(false);
			}
		} 
		else
		{
			QTimer::singleShot(0, qApp, SLOT(quit()));
		}
	}
	else
	{
		QTimer::singleShot(0, qApp, SLOT(quit()));
	}
}

void sterna::updatePrinterStat(QWidget* i)
{
	if (qobject_cast<QMyIspratnici*>(i))
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}
	else if (qobject_cast<QMyPriemnica*>(i))
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}
	else if (qobject_cast<QLager*>(i))
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}

    else if (qobject_cast<QLSearch*>(i))
    {
        ui.actionPrinter->setEnabled(true);
        ui.actionPreview->setEnabled(true);
    }

    else if (qobject_cast<QAnalitikaArtikli*>(i))
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}

	else if (qobject_cast<QAnalitikaKomintenti*>(i))
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}

	else if (qobject_cast<QMyFakturi*>(i))
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}
	else if (qobject_cast<QMyProFakturi*>(i))
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}

	else if (qobject_cast<QDnevenpromet*>(i))
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}
	else if (qobject_cast<QMyIzjava*>(i))
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}
	else if (qobject_cast<QMyPLTM*>(i))
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}
	else if (qobject_cast<QMyProdPovratnica*>(i))
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}
	else if (qobject_cast<QMyProdSmetka*>(i))
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}
	else
	{
		ui.actionPrinter->setEnabled(false);
		ui.actionPreview->setEnabled(false);
	}

}



void sterna::disablePrintPreview(bool stat)
{
	if (stat)
	{
		ui.actionPrinter->setEnabled(false);
		ui.actionPreview->setEnabled(false);
	}
	else
	{
		ui.actionPrinter->setEnabled(true);
		ui.actionPreview->setEnabled(true);
	}
}


void sterna::on_actionNalog_triggered()
{
	m_mynalog = showMyWidget<QMyNalog, QWidget, QWidget>(m_mynalog, moi_nalog, ui.centralWidget, NULL);
	ui.actionPrinter->setEnabled(true);
    connect(m_mynalog, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
    connect(m_mynalog, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
    connect(m_mynalog, SIGNAL(signProizvodiFromNalog(QWidget*, QString)), this, SLOT(callProcNormativFromNalog(QWidget*, QString)));
    connect(m_mynalog, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
    connect(m_mynalog, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
}

void sterna::on_actionNormativ_triggered()
{
	m_mynormativ = showMyWidget<QMyNormativ, QWidget, QWidget>(m_mynormativ, moi_normativ, ui.centralWidget, NULL);
	ui.actionPrinter->setEnabled(true);
	connect(m_mynormativ, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	connect(m_mynormativ, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
	connect(m_mynormativ, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_mynormativ, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
}

void sterna::on_actionNaracka_triggered()
{
	m_mynaracki = showMyWidget<QMyNaracki, QWidget, QWidget>(m_mynaracki, moi_mynaracki, ui.centralWidget, NULL);
	ui.actionPrinter->setEnabled(true);
	connect(m_mynaracki, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	connect(m_mynaracki, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
    connect(m_mynaracki, SIGNAL(signProizvodiFromNalog(QWidget*, QString)), this, SLOT(callProcNormativFromNalog(QWidget*, QString)));
    connect(m_mynaracki, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_mynaracki, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
}

void sterna::on_actionVraboteni_triggered()
{
	m_employe = showMyWidget<QMyEmploye, QWidget, QWidget>(m_employe, moi_employe, ui.centralWidget, NULL);
}

void sterna::on_actionLager_triggered()
{
    m_mylager = showMyWidget<QLager, QWidget, QWidget>(m_mylager, moi_lagerlista, ui.centralWidget, NULL);
//     connect(m_mypriemnici, SIGNAL(signKomintentiFromPriemnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
//     connect(m_mypriemnici, SIGNAL(signArtikliFromPriemnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
}

void sterna::on_actionLagerListaProdavnica_triggered()
{
	m_myLagerProdavnica = showMyWidget<QLagerProdavnica, QWidget, QWidget>(m_myLagerProdavnica, moi_lagerProdavnica, ui.centralWidget, NULL);
	//     connect(m_mypriemnici, SIGNAL(signKomintentiFromPriemnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
	//     connect(m_mypriemnici, SIGNAL(signArtikliFromPriemnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
}

void sterna::on_actionCenovnik_triggered()
{
	m_myCenovnik = showMyWidget<QCenovnik, QWidget, QWidget>(m_myCenovnik, moi_Cenovnik, ui.centralWidget, NULL);
	//     connect(m_mypriemnici, SIGNAL(signKomintentiFromPriemnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
	//     connect(m_mypriemnici, SIGNAL(signArtikliFromPriemnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
}

void sterna::on_actionLSearch_triggered()
{
    m_myLSearch = showMyWidget<QLSearch, QWidget, QWidget>(m_myLSearch, moi_LSearch, ui.centralWidget, NULL);
    //     connect(m_mypriemnici, SIGNAL(signKomintentiFromPriemnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
    //     connect(m_mypriemnici, SIGNAL(signArtikliFromPriemnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
}

void sterna::on_actionAnalitikaArtikli_triggered()
{
	m_analitikaArtikli = showMyWidget<QAnalitikaArtikli, QWidget, QWidget>(m_analitikaArtikli, moi_analitikaArtikli, ui.centralWidget, NULL);
	//     connect(m_mypriemnici, SIGNAL(signKomintentiFromPriemnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
	//     connect(m_mypriemnici, SIGNAL(signArtikliFromPriemnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
}

void sterna::on_actionAnalitikaKomintenti_triggered()
{
	m_analitikaKomintenti = showMyWidget<QAnalitikaKomintenti, QWidget, QWidget>(m_analitikaKomintenti, moi_analitikaKomintenti, ui.centralWidget, NULL);
	//     connect(m_mypriemnici, SIGNAL(signKomintentiFromPriemnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
	//     connect(m_mypriemnici, SIGNAL(signArtikliFromPriemnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
}

void sterna::on_actionDnevenPromet_triggered()
{
	m_dnevenpromet = showMyWidget<QDnevenpromet, QWidget, QWidget>(m_dnevenpromet, moi_dnevenpromet, ui.centralWidget, NULL);
//	connect(m_dnevenpromet, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
	//     connect(m_mypriemnici, SIGNAL(signKomintentiFromPriemnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
	//     connect(m_mypriemnici, SIGNAL(signArtikliFromPriemnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
}

void sterna::on_actionAnalitikaKomintent_triggered()
{
    m_mykomintenti_analitika = showMyWidget<QKomintentiAnalitika, QWidget, QWidget>(m_mykomintenti_analitika, moi_komintenti_analitika, ui.centralWidget, NULL);
    //     connect(m_mypriemnici, SIGNAL(signKomintentiFromPriemnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
    //     connect(m_mypriemnici, SIGNAL(signArtikliFromPriemnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
}

void sterna::on_action_KomintentiLista_triggered()
{
	m_mykomintenti = showMyWidget<QMyKomintenti, QWidget, QWidget>(m_mykomintenti, moi_komintenti, ui.centralWidget, NULL);
}


void sterna::on_action_MyArtikli_triggered()
{
	m_myartikli = showMyWidget<QMyArtikli, QWidget, QWidget>(m_myartikli, moi_artikli, ui.centralWidget, NULL);
	connect(m_myartikli, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	connect(m_myartikli, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));

}

void sterna::on_actionMyIspratnici_triggered()
{
	m_myispratnici = showMyWidget<QMyIspratnici, QWidget, QWidget>(m_myispratnici, moi_ispratnici, ui.centralWidget, NULL);
	ui.actionPrinter->setEnabled(true);
	connect(m_myispratnici, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	connect(m_myispratnici, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcLagerFromIspratnica(QWidget*, QString)));
	connect(m_myispratnici, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_myispratnici, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));

}

void sterna::on_actionMyFinNal_triggered()
{
	m_myFinNal = showMyWidget<QMyFinNal, QWidget, QWidget>(m_myFinNal, moi_finnal, ui.centralWidget, NULL);
	ui.actionPrinter->setEnabled(true);
	connect(m_myFinNal, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));

	connect(m_myFinNal, SIGNAL(signIzlezniFakturi(QWidget*, QString)), this, SLOT(callProcIzlezniFakturi(QWidget*, QString)));
	connect(m_myFinNal, SIGNAL(signPriemnici(QWidget*, QString)), this, SLOT(callProcPriemnici(QWidget*, QString)));
	connect(m_myFinNal, SIGNAL(signVlezniFakturi(QWidget*, QString)), this, SLOT(callProcVlezniFakturi(QWidget*, QString)));
	connect(m_myFinNal, SIGNAL(signIspratnici(QWidget*, QString)), this, SLOT(callProcIspratnici(QWidget*, QString)));
	connect(m_myFinNal, SIGNAL(signNalogProizvodstvo(QWidget*, QString)), this, SLOT(callProcNalogProizvodstvo(QWidget*, QString)));
	connect(m_myFinNal, SIGNAL(signKalkulacija(QWidget*, QString)), this, SLOT(callProcKalkulacija(QWidget*, QString)));

	connect(m_myFinNal, SIGNAL(signKontoListaFromNalog(QWidget*, QString)), this, SLOT(callProcKontoLista(QWidget*, QString)));

	connect(m_myFinNal, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_myFinNal, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));

}


void sterna::on_actionMyPriemnici_triggered()
{
	m_mypriemnici = showMyWidget<QMyPriemnica, QWidget, QWidget>(m_mypriemnici, moi_priemnici, ui.centralWidget, NULL);
 	connect(m_mypriemnici, SIGNAL(signKomintentiFromPriemnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
	connect(m_mypriemnici, SIGNAL(signArtikliFromPriemnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
	connect(m_mypriemnici, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));

}

void sterna::on_actionKalkulacii_triggered()
{
	m_mykalkulacija = showMyWidget<QMyKalkulacija, QWidget, QWidget>(m_mykalkulacija, moi_kalkulacija, ui.centralWidget, NULL);
	connect(m_mykalkulacija, SIGNAL(signKomintentiFromKalkulacija(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
	connect(m_mykalkulacija, SIGNAL(signArtikliFromKalkulacija(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
	connect(m_mykalkulacija, SIGNAL(signImportArtikliFromKalkulacija(QWidget*, QString)), this, SLOT(callProcPriemnicaFromKalkulacii(QWidget*, QString)));
	connect(m_mykalkulacija, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));

}


void sterna::on_actionIzjava_triggered()
{
	m_myizjava = showMyWidget<QMyIzjava, QWidget, QWidget>(m_myizjava, moi_izjava, ui.centralWidget, NULL);
	connect(m_myizjava, SIGNAL(signKomintentiFromIzjava(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
	connect(m_myizjava, SIGNAL(signArtikliFromIzjava(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
	connect(m_myizjava, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));

}


void sterna::on_actionMyPovratnica_triggered()
{
	m_mypovratnica = showMyWidget<QMyPovratnica, QWidget, QWidget>(m_mypovratnica, moi_povratnica, ui.centralWidget, NULL);
	connect(m_mypovratnica, SIGNAL(signKomintentiFromPovratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
	connect(m_mypovratnica, SIGNAL(signArtikliFromPovratnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
}


void sterna::on_actionMyFakturi_triggered()
{
	m_myfaktura = showMyWidget<QMyFakturi, QWidget, QWidget>(m_myfaktura, moi_faktura, ui.centralWidget, NULL);
    connect(m_myfaktura, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
    connect(m_myfaktura, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcLagerFromIspratnica(QWidget*, QString)));
	connect(m_myfaktura, SIGNAL(signImportArtikliFromIspratnici(QWidget*, QString)), this, SLOT(callProcIspratnicaFromIzlFakturi(QWidget*, QString)));
	connect(m_myfaktura, SIGNAL(signImportArtikliFromProfakturi(QWidget*, QString)), this, SLOT(callProcProfakturaFromIzlFakturi(QWidget*, QString)));
	connect(m_myfaktura, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_myfaktura, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
}


void sterna::on_actionSmetka_triggered()
{
	m_mysmetki = showMyWidget<QMySmetki, QWidget, QWidget>(m_mysmetki, moi_smetki, ui.centralWidget, NULL);
	connect(m_mysmetki, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	connect(m_mysmetki, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcLagerProdavnicaFromIspratnica(QWidget*, QString)));
	connect(m_mysmetki, SIGNAL(signImportArtikliFromIspratnici(QWidget*, QString)), this, SLOT(callProcIspratnicaFromIzlFakturi(QWidget*, QString)));
	connect(m_mysmetki, SIGNAL(signImportArtikliFromProfakturi(QWidget*, QString)), this, SLOT(callProcProfakturaFromIzlFakturi(QWidget*, QString)));
	connect(m_mysmetki, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_mysmetki, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
}

void sterna::on_actionNivelacija_triggered()
{
	m_myNivelacija = showMyWidget<QMyNivelacija, QWidget, QWidget>(m_myNivelacija, moi_nivelacija, ui.centralWidget, NULL);
	connect(m_myNivelacija, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	connect(m_myNivelacija, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcLagerFromIspratnica(QWidget*, QString)));
	connect(m_myNivelacija, SIGNAL(signImportArtikliFromIspratnici(QWidget*, QString)), this, SLOT(callProcIspratnicaFromIzlFakturi(QWidget*, QString)));
	connect(m_myNivelacija, SIGNAL(signImportArtikliFromProfakturi(QWidget*, QString)), this, SLOT(callProcProfakturaFromIzlFakturi(QWidget*, QString)));
	connect(m_myNivelacija, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_myNivelacija, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
}

void sterna::on_actionPLTM_triggered()
{
	m_pltm = showMyWidget<QMyPLTM, QWidget, QWidget>(m_pltm, moi_pltm, ui.centralWidget, NULL);
	connect(m_pltm, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	connect(m_pltm, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
	connect(m_pltm, SIGNAL(signImportArtikliFromIspratnici(QWidget*, QString)), this, SLOT(callProcIspratnicaFromIzlFakturi(QWidget*, QString)));
	connect(m_pltm, SIGNAL(signImportArtikliFromProfakturi(QWidget*, QString)), this, SLOT(callProcProfakturaFromIzlFakturi(QWidget*, QString)));
	connect(m_pltm, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_pltm, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
}

void sterna::on_actionProPovratnica_triggered()
{
	m_prodPovratnica = showMyWidget<QMyProdPovratnica, QWidget, QWidget>(m_prodPovratnica, moi_proPovratnica, ui.centralWidget, NULL);
	connect(m_prodPovratnica, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	connect(m_prodPovratnica, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
	connect(m_prodPovratnica, SIGNAL(signImportArtikliFromIspratnici(QWidget*, QString)), this, SLOT(callProcIspratnicaFromIzlFakturi(QWidget*, QString)));
	connect(m_prodPovratnica, SIGNAL(signImportArtikliFromProfakturi(QWidget*, QString)), this, SLOT(callProcProfakturaFromIzlFakturi(QWidget*, QString)));
	connect(m_prodPovratnica, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_prodPovratnica, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
}

void sterna::on_actionETM_triggered()
{
	m_etm = showMyWidget<QMyETM, QWidget, QWidget>(m_etm, moi_etm, ui.centralWidget, NULL);
	connect(m_etm, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	connect(m_etm, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
	connect(m_etm, SIGNAL(signImportArtikliFromIspratnici(QWidget*, QString)), this, SLOT(callProcIspratnicaFromIzlFakturi(QWidget*, QString)));
	connect(m_etm, SIGNAL(signImportArtikliFromProfakturi(QWidget*, QString)), this, SLOT(callProcProfakturaFromIzlFakturi(QWidget*, QString)));
	connect(m_etm, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_etm, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
}

void sterna::on_actionProdSmetki_triggered()
{
	m_prodsmetka = showMyWidget<QMyProdSmetka, QWidget, QWidget>(m_prodsmetka, moi_prodsmetka, ui.centralWidget, NULL);
	connect(m_prodsmetka, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	connect(m_prodsmetka, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
	connect(m_prodsmetka, SIGNAL(signImportArtikliFromIspratnici(QWidget*, QString)), this, SLOT(callProcIspratnicaFromIzlFakturi(QWidget*, QString)));
	connect(m_prodsmetka, SIGNAL(signImportArtikliFromProfakturi(QWidget*, QString)), this, SLOT(callProcProfakturaFromIzlFakturi(QWidget*, QString)));
	connect(m_prodsmetka, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_prodsmetka, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
}

void sterna::on_actionProdNivelacija_triggered()
{
	m_prodNivelacija = showMyWidget<QMyProdNivelacija, QWidget, QWidget>(m_prodNivelacija, moi_prodNivelacija, ui.centralWidget, NULL);
	connect(m_prodNivelacija, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	connect(m_prodNivelacija, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
	connect(m_prodNivelacija, SIGNAL(signImportArtikliFromIspratnici(QWidget*, QString)), this, SLOT(callProcIspratnicaFromIzlFakturi(QWidget*, QString)));
	connect(m_prodNivelacija, SIGNAL(signImportArtikliFromProfakturi(QWidget*, QString)), this, SLOT(callProcProfakturaFromIzlFakturi(QWidget*, QString)));
	connect(m_prodNivelacija, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_prodNivelacija, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
}

void sterna::on_actionMyFakturiVlezni_triggered()
{
    m_myfakturavlezna = showMyWidget<QFakturiVlezni, QWidget, QWidget>(m_myfakturavlezna, moi_fakturavlezna, ui.centralWidget, NULL);
    connect(m_myfakturavlezna, SIGNAL(signKomintentiFromPriemnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
    connect(m_myfakturavlezna, SIGNAL(signArtikliFromPriemnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
    connect(m_myfakturavlezna, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
}

void sterna::on_actionProFaktura_triggered()
{
	m_myprofakturi = showMyWidget<QMyProFakturi, QWidget, QWidget>(m_myprofakturi, moi_profakturi, ui.centralWidget, NULL);
	connect(m_myprofakturi, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	connect(m_myprofakturi, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcLagerFromIspratnica(QWidget*, QString)));
    connect(m_myprofakturi, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
    connect(m_myprofakturi, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
	connect(m_myprofakturi, SIGNAL(disablePrint(bool )), this, SLOT(disablePrintPreview(bool )));
}

void sterna::on_actionFinansova_Kartica_triggered()
{
	m_finanalitikaKomintenti = showMyWidget<QFinAnalitKomintenti, QWidget, QWidget>(m_finanalitikaKomintenti, moi_finanalitikaKomintenti, ui.centralWidget, NULL);
	//     connect(m_mypriemnici, SIGNAL(signKomintentiFromPriemnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromPriemnica(QWidget*, QString)));
	//     connect(m_mypriemnici, SIGNAL(signArtikliFromPriemnica(QWidget*, QString)), this, SLOT(callProcArtikliFromPriemnica(QWidget*, QString)));
	connect(m_finanalitikaKomintenti, SIGNAL(signPrint()), this, SLOT(filePrintPreview()));
}

void sterna::on_actionKasi_triggered()
{
    m_mykasa = showMyWidget<QMyKasa, QWidget, QWidget>(m_mykasa, moi_kasa, ui.centralWidget, NULL);
    connect(m_mykasa, SIGNAL(signKomintentiFromKasa(QWidget*)), this, SLOT(callProcKomintentiFromKasa(QWidget*)));
    connect(m_mykasa, SIGNAL(signArtikliFromKasa(QWidget*)), this, SLOT(callProcArtikliFromKasa(QWidget*)));
}

void sterna::on_actionBanki_triggered()
{
    m_mybanki = showMyWidget<QMyBanki, QWidget, QWidget>(m_mybanki, moi_banki, ui.centralWidget, NULL);
}

void sterna::on_actionKontenPlan_triggered()
{
	m_mykontenplan = showMyWidget<QMyKontenPlan, QWidget, QWidget>(m_mykontenplan, moi_kontenplan, ui.centralWidget, NULL);
}

void sterna::on_actionIzvodi_triggered()
{
// 	m_myizvod = showMyWidget<QMyIzvod, QWidget, QWidget>(m_myizvod, moi_izvod, ui.centralWidget, NULL);
// 	connect(m_myizvod, SIGNAL(signZiroSmetkiFromIzvod(QWidget*, QString)), this, SLOT(callProcZiroSmetkiFromIzvod(QWidget*, QString)));
// 	connect(m_myizvod, SIGNAL(signFakturiFromIzvod(QWidget*, QString, int)), this, SLOT(callProcFakturiFromIzvod(QWidget*, QString, int)));

	m_myizvod = showMyWidget<QMyIzvod, QWidget, QWidget>(m_myizvod, moi_izvod, ui.centralWidget, NULL);
	connect(m_myizvod, SIGNAL(signZiroSmetkiFromIzvod(QWidget*, QString)), this, SLOT(callProcZiroSmetkiFromIzvod(QWidget*, QString)));
	connect(m_myizvod, SIGNAL(signFakturiFromIzvod(QWidget*, QString, int)), this, SLOT(callProcFakturiFromIzvod(QWidget*, QString, int)));
	connect(m_myizvod, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
}

void sterna::on_actionIzvestai_triggered()
{
    m_myizvestai = showMyWidget<QIzvestai, QWidget, QWidget>(m_myizvestai, moi_izvestai, ui.centralWidget, NULL);
}


void sterna::on_actionClose_triggered()
{
	if (m_left)
	{
		m_left->setFocus();
		m_left->getSelection();
	}
	
	closeMyWidget();
}

/////////////////////////////////////////////////////////////////////////////
void sterna::callProcArtikliFromFaktura(QMyBaseWidget * widget)
{
	QMyFakturi * sourceWidget = qobject_cast<QMyFakturi*>(widget);
	m_myartikli = showMyWidget<QMyArtikli, QWidget, QWidget>(m_myartikli, moi_artikli, ui.centralWidget, sourceWidget);
	m_myartikli->pressF2();
}

void sterna::callProcKomintentiFromFaktura(QMyBaseWidget * widget)
{
	QMyFakturi * sourceWidget = qobject_cast<QMyFakturi*>(widget);
	m_mykomintenti = showMyWidget<QMyKomintenti, QWidget, QWidget>(m_mykomintenti, moi_komintenti, ui.centralWidget, sourceWidget);
	m_mykomintenti->raise();
}

void sterna::callProcKomintentiFromPriemnica(QWidget * widget, QString text)
{
	m_mykomintenti = showMyWidget<QMyKomintenti, QWidget, QWidget>(m_mykomintenti, moi_komintenti, ui.centralWidget, widget);
	connect(m_mykomintenti, SIGNAL(eCloseKomintentiFromPriemnica()), this, SLOT(closeMyWidget()));
    connect(m_mykomintenti, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
    m_mykomintenti->setInitSearchText(text);
	m_mykomintenti->raise();
}


void sterna::callProcArtikliFromPriemnica(QWidget * widget, QString text)
{
	m_myartikli = showMyWidget<QMyArtikli, QWidget, QWidget>(m_myartikli, moi_artikli, ui.centralWidget, widget);
	connect(m_myartikli, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
    connect(m_myartikli, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	connect(m_myartikli, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
	m_myartikli->setInitSearchText(text);
	m_myartikli->raise();
}


void sterna::callProcPriemnicaFromKalkulacii(QWidget * widget, QString text)
{
	m_mypriemnici = showMyWidget<QMyPriemnica, QWidget, QWidget>(m_mypriemnici, moi_priemnici, ui.centralWidget, widget);
	connect(m_mypriemnici, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
	connect(m_mypriemnici, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_mypriemnici->raise();
}


void sterna::callProcIspratnicaFromIzlFakturi(QWidget * widget, QString text)
{
	m_myispratnici = showMyWidget<QMyIspratnici, QWidget, QWidget>(m_myispratnici, moi_ispratnici, ui.centralWidget, widget);
	connect(m_myispratnici, SIGNAL(signCloseMyWidget()), this, SLOT(closeMyWidget()));
	connect(m_myispratnici, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_myispratnici->raise();
}

void sterna::callProcProfakturaFromIzlFakturi(QWidget * widget, QString text)
{
	m_myprofakturi = showMyWidget<QMyProFakturi, QWidget, QWidget>(m_myprofakturi, moi_profakturi, ui.centralWidget, widget);
	connect(m_myprofakturi, SIGNAL(signCloseMyWidget()), this, SLOT(closeMyWidget()));
	connect(m_myprofakturi, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_myprofakturi->raise();
}

void sterna::callProcNormativFromNalog(QWidget * widget, QString text)
{
	m_mynormativ = showMyWidget<QMyNormativ, QWidget, QWidget>(m_mynormativ, moi_normativ, ui.centralWidget, widget);
	connect(m_mynormativ, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
	connect(m_mynormativ, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
//	m_mynormativ->setInitSearchText(text);
	m_mynormativ->raise();
}
void sterna::callProcKomintentiFromIspratnica(QWidget * widget, QString text)
{
	m_mykomintenti = showMyWidget<QMyKomintenti, QWidget, QWidget>(m_mykomintenti, moi_komintenti, ui.centralWidget, widget);
	connect(m_mykomintenti, SIGNAL(eCloseKomintentiFromPriemnica()), this, SLOT(closeMyWidget()));
    connect(m_mykomintenti, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_mykomintenti->setInitSearchText(text);
	m_mykomintenti->raise();
}
void sterna::callProcArtikliFromIspratnica(QWidget * widget, QString text)
{
	m_myartikli = showMyWidget<QMyArtikli, QWidget, QWidget>(m_myartikli, moi_artikli, ui.centralWidget, widget);
	connect(m_myartikli, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
    connect(m_myartikli, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_myartikli->setInitSearchText(text);
	m_myartikli->raise();
}

void sterna::callProcIzlezniFakturi(QWidget * widget, QString text)
{
	m_myfaktura = showMyWidget<QMyFakturi, QWidget, QWidget>(m_myfaktura, moi_faktura, ui.centralWidget, widget);
	connect(m_myfaktura, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
	connect(m_myfaktura, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_myfaktura->raise();
}
void sterna::callProcPriemnici(QWidget * widget, QString text)
{
	m_mypriemnici = showMyWidget<QMyPriemnica, QWidget, QWidget>(m_mypriemnici, moi_priemnici, ui.centralWidget, widget);
	connect(m_mypriemnici, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
	connect(m_mypriemnici, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_mypriemnici->raise();

}
void sterna::callProcVlezniFakturi(QWidget * widget, QString text)
{
	m_myfakturavlezna = showMyWidget<QFakturiVlezni, QWidget, QWidget>(m_myfakturavlezna, moi_fakturavlezna, ui.centralWidget, widget);
	connect(m_myfakturavlezna, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
	connect(m_myfakturavlezna, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_myfakturavlezna->raise();
}
void sterna::callProcIspratnici(QWidget * widget, QString text)
{
	m_myispratnici = showMyWidget<QMyIspratnici, QWidget, QWidget>(m_myispratnici, moi_ispratnici, ui.centralWidget, widget);
	connect(m_myispratnici, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
	connect(m_myispratnici, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_myispratnici->raise();
}
void sterna::callProcNalogProizvodstvo(QWidget * widget, QString text)
{
	m_mynalog = showMyWidget<QMyNalog, QWidget, QWidget>(m_mynalog, moi_nalog, ui.centralWidget, widget);
	connect(m_mynalog, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
	connect(m_mynalog, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_mynalog->raise();
}

void sterna::callProcKalkulacija(QWidget * widget, QString text)
{
	m_mykalkulacija = showMyWidget<QMyKalkulacija, QWidget, QWidget>(m_mykalkulacija, moi_kalkulacija, ui.centralWidget, widget);
	connect(m_mykalkulacija, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
	connect(m_mykalkulacija, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_mykalkulacija->raise();
}


void sterna::callProcKontoLista(QWidget * widget, QString text)
{
	m_mykontenplan = showMyWidget<QMyKontenPlan, QWidget, QWidget>(m_mykontenplan, moi_kontenplan, ui.centralWidget, widget);
	connect(m_mykontenplan, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
	connect(m_mykontenplan, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_mykontenplan->raise();
}

void sterna::callProcLagerFromIspratnica(QWidget * widget, QString text)
{
    m_mylager = showMyWidget<QLager, QWidget, QWidget>(m_mylager, moi_lagerlista, ui.centralWidget, widget);
    connect(m_mylager, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
    connect(m_mylager, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
    m_mylager->setInitSearchText(text);
    m_mylager->raise();
}

void sterna::callProcLagerProdavnicaFromIspratnica(QWidget * widget, QString text)
{
	m_myLagerProdavnica = showMyWidget<QLagerProdavnica, QWidget, QWidget>(m_myLagerProdavnica, moi_lagerProdavnica, ui.centralWidget, widget);
	connect(m_myLagerProdavnica, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
	connect(m_myLagerProdavnica, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_myLagerProdavnica->setInitSearchText(text);
	m_myLagerProdavnica->raise();
}


void sterna::callProcKomintentiFromFaktura(QWidget * widget)
{
	m_mykomintenti = showMyWidget<QMyKomintenti, QWidget, QWidget>(m_mykomintenti, moi_komintenti, ui.centralWidget, widget);
	connect(m_mykomintenti, SIGNAL(eCloseKomintentiFromPriemnica()), this, SLOT(closeMyWidget()));
    connect(m_mykomintenti, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_mykomintenti->raise();
}
void sterna::callProcArtikliFromFaktura(QWidget * widget)
{
	m_myartikli = showMyWidget<QMyArtikli, QWidget, QWidget>(m_myartikli, moi_artikli, ui.centralWidget, widget);
	connect(m_myartikli, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
	m_myartikli->raise();
}

void sterna::callProcKomintentiFromPovratnica(QWidget * widget, QString info)
{
	m_mykomintenti = showMyWidget<QMyKomintenti, QWidget, QWidget>(m_mykomintenti, moi_komintenti, ui.centralWidget, widget);
	connect(m_mykomintenti, SIGNAL(eCloseKomintentiFromPriemnica()), this, SLOT(closeMyWidget()));
    connect(m_mykomintenti, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	m_mykomintenti->raise();
}
void sterna::callProcArtikliFromPovratnica(QWidget * widget,QString info)
{
	m_myartikli = showMyWidget<QMyArtikli, QWidget, QWidget>(m_myartikli, moi_artikli, ui.centralWidget, widget);
	connect(m_myartikli, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
	connect(m_myartikli, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
	
	m_myartikli->raise();
}

void sterna::callProcKomintentiFromProFakturi(QWidget * widget)
{
    m_mykomintenti = showMyWidget<QMyKomintenti, QWidget, QWidget>(m_mykomintenti, moi_komintenti, ui.centralWidget, widget);
    connect(m_mykomintenti, SIGNAL(eCloseKomintentiFromPriemnica()), this, SLOT(closeMyWidget()));
    connect(m_mykomintenti, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
    m_mykomintenti->raise();
}
void sterna::callProcArtikliFromProFakturi(QWidget * widget, QString info)
{
    m_myartikli = showMyWidget<QMyArtikli, QWidget, QWidget>(m_myartikli, moi_artikli, ui.centralWidget, widget);
    connect(m_myartikli, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
    connect(m_myartikli, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
    m_myartikli->raise();
}

void sterna::callProcKomintentiFromKasa(QWidget * widget)
{
    m_mykomintenti = showMyWidget<QMyKomintenti, QWidget, QWidget>(m_mykomintenti, moi_komintenti, ui.centralWidget, widget);
    connect(m_mykomintenti, SIGNAL(eCloseKomintentiFromPriemnica()), this, SLOT(closeMyWidget()));
    connect(m_mykomintenti, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
    m_mykomintenti->raise();
}

void sterna::callProcZiroSmetkiFromIzvod(QWidget * widget, QString ziro)
{
    m_mybanki = showMyWidget<QMyBanki, QWidget, QWidget>(m_mybanki, moi_banki, ui.centralWidget, widget);
    connect(m_mybanki, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
    m_mybanki->setInitSearchText(ziro);
    m_mybanki->raise();
}


void sterna::callProcFakturiFromIzvod(QWidget * widget, QString ziro, int tip)
{
	if (tip == 1)
	{
		m_myfaktura = showMyWidget<QMyFakturi, QWidget, QWidget>(m_myfaktura, moi_faktura, ui.centralWidget, widget);
		connect(m_myfaktura, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
		connect(m_myfaktura, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
		connect(m_myfaktura, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcLagerFromIspratnica(QWidget*, QString)));

		m_myfaktura->setInitSearchText(ziro);
        m_myfaktura->raise();
	}
    else if (tip == 2)
	{
		m_myfakturavlezna = showMyWidget<QFakturiVlezni, QWidget, QWidget>(m_myfakturavlezna, moi_fakturavlezna, ui.centralWidget, widget);
		connect(m_myfakturavlezna, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
		connect(m_myfakturavlezna, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
		connect(m_myfakturavlezna, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcLagerFromIspratnica(QWidget*, QString)));

		m_myfakturavlezna->setInitSearchText(ziro);
        m_myfakturavlezna->raise();
	}
    else if (tip == 3)
    {
        m_myprofakturi = showMyWidget<QMyProFakturi, QWidget, QWidget>(m_myprofakturi, moi_profakturi, ui.centralWidget, widget);
        connect(m_myprofakturi, SIGNAL(signKomintentiFromIspratnica(QWidget*, QString)), this, SLOT(callProcKomintentiFromIspratnica(QWidget*, QString)));
        connect(m_myprofakturi, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
        connect(m_myprofakturi, SIGNAL(signArtikliFromIspratnica(QWidget*, QString)), this, SLOT(callProcArtikliFromProFakturi(QWidget*, QString)));
        m_myprofakturi->setInitSearchText(ziro);
        m_myprofakturi->raise();
    }
}


void sterna::callProcArtikliFromKasa(QWidget * widget)
{
    m_myartikli = showMyWidget<QMyArtikli, QWidget, QWidget>(m_myartikli, moi_artikli, ui.centralWidget, widget);
    connect(m_myartikli, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
    m_myartikli->raise();
}

void sterna::callProcKomintentiFromIzvod(QWidget * widget)
{
    m_mykomintenti = showMyWidget<QMyKomintenti, QWidget, QWidget>(m_mykomintenti, moi_komintenti, ui.centralWidget, widget);
    connect(m_mykomintenti, SIGNAL(eCloseKomintentiFromPriemnica()), this, SLOT(closeMyWidget()));
    connect(m_mykomintenti, SIGNAL(eupdateNanigator(QWidget*, QWidget*)), this, SLOT(updateNavigator(QWidget*, QWidget*)));
    m_mykomintenti->raise();
}
void sterna::callProcArtikliFromIzvod(QWidget * widget)
{
    m_myartikli = showMyWidget<QMyArtikli, QWidget, QWidget>(m_myartikli, moi_artikli, ui.centralWidget, widget);
    connect(m_myartikli, SIGNAL(eCloseArtikliFromPriemnica()), this, SLOT(closeMyWidget()));
    m_myartikli->raise();
}

void sterna::on_actionPrinter_triggered()
{
    m_left->getSelection();
	if (qobject_cast<QMyArtikli*>(qApp->focusWidget()))
	{
		if (m_myartikli->getModel())
		{
			m_selectedPrint = SV_ART;
			//filePrintPreview();
		}
	}
	if (qobject_cast<QMyKomintenti*>(qApp->focusWidget()))
	{
		if (m_mykomintenti->getModel())
		{
			m_selectedPrint = SV_KOM;
			//filePrintPreview();
		}
	}
	if (qobject_cast<QMyIzjava*>(qApp->focusWidget()))
	{
		if (m_myizjava->getModel())
		{
			m_selectedPrint = SV_IZJ;
			filePrintPreview();
		}
	}

	if (qobject_cast<QDnevenpromet*>(qApp->focusWidget()))
	{
		if (m_dnevenpromet->getModel())
		{
			m_selectedPrint = SV_DNVIZV;
			filePrintPreview();
		}
	}

	if (qobject_cast<QMyIspratnici*>(qApp->focusWidget()))
    {
        if (m_myispratnici->getModel() && m_myispratnici->getModel2())
        {
            //
            if (m_myispratnici->printTovarenList())
            {
                m_selectedPrint = SV_TVL;
            }
            else
            {
                if(m_myispratnici->printMalaIspratnica())
				{
					m_selectedPrint = SV_ISP_MALA;
				}
				else
				{
					m_selectedPrint = SV_ISP;
				}
            }
            filePrintPreview();
        }
    }
    if (qobject_cast<QMyPriemnica*>(qApp->focusWidget()))
    {
        if (m_mypriemnici->getModel() && m_mypriemnici->getModel2())
        {
            m_selectedPrint = SV_PRI;
            filePrintPreview();
        }
    }
    if (qobject_cast<QMyPovratnica*>(qApp->focusWidget()))
    {
        m_selectedPrint = SV_POV;
    }
    
	if (qobject_cast<QMyFakturi*>(qApp->focusWidget()))
    {
        if (m_myfaktura->getModel() && m_myfaktura->getModel2())
        {
            m_selectedPrint = SV_FKT;
            filePrintPreview();
        }
    }

// 	if (qobject_cast<QFakturiVlezni*>(qApp->focusWidget()))
// 	{
// 		if (m_myfakturavlezna->getModel() && m_myfakturavlezna->getModel2())
// 		{
// 			m_selectedPrint = SV_FKT_VLEZNA;
// 			filePrintPreview();
// 		}
// 	}
	
	if (qobject_cast<QMyDdv*>(qApp->focusWidget()))
    {
        m_selectedPrint = SV_DDV;
    }
    if (qobject_cast<QMyProFakturi*>(qApp->focusWidget()))
    {
        if (m_myprofakturi->getModel() && m_myprofakturi->getModel2())
        {
            m_selectedPrint = SV_PFKT;
            filePrintPreview();
        }
    }
    if (qobject_cast<QMyKasa*>(qApp->focusWidget()))
    {
        m_selectedPrint = SV_KAS;
    }
    if (qobject_cast<QMyBanki*>(qApp->focusWidget()))
    {
        if (m_mykomintenti->getModel())
        {
            m_selectedPrint = SV_BNK;    
         //   filePrintPreview();
        }
        
    }
    if (qobject_cast<QMyIzvod*>(qApp->focusWidget()))
    {
        m_selectedPrint = SV_IZV;
    }
    if (qobject_cast<QIzvestai*>(qApp->focusWidget()))
    {
        m_selectedPrint = SV_IZVES;
    }
    if (qobject_cast<QLager*>(qApp->focusWidget()))
    {
        m_selectedPrint = SV_LGR;
        filePrintPreview();
    }
	if (qobject_cast<QAnalitikaArtikli*>(qApp->focusWidget()))
	{
		m_selectedPrint = SV_ANA;
		filePrintPreview(QPrinter::Landscape);
	}
	if (qobject_cast<QAnalitikaKomintenti*>(qApp->focusWidget()))
	{
		m_selectedPrint = SV_ANK;
		filePrintPreview();
	}


}

void sterna::on_actionPreview_triggered()
{
	m_left->getSelection();
	if (qobject_cast<QMyArtikli*>(qApp->focusWidget()))
	{
		if (m_myartikli->getModel())
		{
			m_selectedPrint = SV_ART;
			//filePrintPreview();
		}
	}
	if (qobject_cast<QMyKomintenti*>(qApp->focusWidget()))
	{
		if (m_mykomintenti->getModel())
		{
			m_selectedPrint = SV_KOM;
			//filePrintPreview();
		}
	}
	if (qobject_cast<QMyIzjava*>(qApp->focusWidget()))
	{
		if (m_myizjava->getModel())
		{
			m_selectedPrint = SV_IZJ;
			filePreview();
		}
	}

	if (qobject_cast<QDnevenpromet*>(qApp->focusWidget()))
	{
		if (m_dnevenpromet->getModel())
		{
			m_selectedPrint = SV_DNVIZV;
			filePreview();
		}
	}

	if (qobject_cast<QMyIspratnici*>(qApp->focusWidget()))
	{
		if (m_myispratnici->getModel() && m_myispratnici->getModel2())
		{
            if (m_myispratnici->printTovarenList())
            {
                m_selectedPrint = SV_TVL;
            }
            else
            {
				if(m_myispratnici->printMalaIspratnica())
				{
					m_selectedPrint = SV_ISP_MALA;
				}
				else
				{
					m_selectedPrint = SV_ISP;
				}
            }
            filePreview();
		}
	}
	if (qobject_cast<QMyPriemnica*>(qApp->focusWidget()))
	{
		if (m_mypriemnici->getModel() && m_mypriemnici->getModel2())
		{
			m_selectedPrint = SV_PRI;
			filePreview();
		}
	}
	if (qobject_cast<QMyPovratnica*>(qApp->focusWidget()))
	{
		m_selectedPrint = SV_POV;
	}

	if (qobject_cast<QMyFakturi*>(qApp->focusWidget()))
	{
		if (m_myfaktura->getModel() && m_myfaktura->getModel2())
		{
			m_selectedPrint = SV_FKT;
			filePreview();
		}
	}
	if (qobject_cast<QMyPLTM*>(qApp->focusWidget()))
	{
		if (m_pltm->getModel() && m_pltm->getModel2())
		{
			m_selectedPrint = SV_PLTM;
			filePreview();
		}
	}
	if (qobject_cast<QMyProdPovratnica*>(qApp->focusWidget()))
	{
		if (m_prodPovratnica->getModel() && m_prodPovratnica->getModel2())
		{
			m_selectedPrint = SV_PPOVR;
			filePreview();
		}
	}

	if (qobject_cast<QMyProdSmetka*>(qApp->focusWidget()))
	{
		if (m_prodsmetka->getModel() && m_prodsmetka->getModel2())
		{
			m_selectedPrint = SV_PSMTK;
			filePreview();
		}
	}


	if (qobject_cast<QMyDdv*>(qApp->focusWidget()))
	{
		m_selectedPrint = SV_DDV;
	}
	if (qobject_cast<QMyProFakturi*>(qApp->focusWidget()))
	{
		if (m_myprofakturi->getModel() && m_myprofakturi->getModel2())
		{
			m_selectedPrint = SV_PFKT;
			filePreview();
		}
	}
	if (qobject_cast<QMyKasa*>(qApp->focusWidget()))
	{
		m_selectedPrint = SV_KAS;
	}
	if (qobject_cast<QMyBanki*>(qApp->focusWidget()))
	{
		if (m_mykomintenti->getModel())
		{
			m_selectedPrint = SV_BNK;    
			//   filePrintPreview();
		}

	}
	if (qobject_cast<QMyIzvod*>(qApp->focusWidget()))
	{
		m_selectedPrint = SV_IZV;
	}
	if (qobject_cast<QIzvestai*>(qApp->focusWidget()))
	{
		m_selectedPrint = SV_IZVES;
	}
	if (qobject_cast<QLager*>(qApp->focusWidget()))
	{
		m_selectedPrint = SV_LGR;
		filePreview();
	}
	if (qobject_cast<QAnalitikaArtikli*>(qApp->focusWidget()))
	{
		m_selectedPrint = SV_ANA;
		filePreview(QPrinter::Landscape);
	}
	if (qobject_cast<QAnalitikaKomintenti*>(qApp->focusWidget()))
	{
		m_selectedPrint = SV_ANK;
		filePreview();
	}
}

void sterna::closeMyWidget()
{
	if (qobject_cast<QFinAnalitKomintenti*>(qApp->focusWidget()))
	{
		deleteMyWidget<QFinAnalitKomintenti>((QFinAnalitKomintenti*)qApp->focusWidget());
		m_finanalitikaKomintenti = NULL;
	}

	if (qobject_cast<QMyEmploye*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyEmploye>((QMyEmploye*)qApp->focusWidget());
		m_employe = NULL;
	}

	if (qobject_cast<QMyFinNal*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyFinNal>((QMyFinNal*)qApp->focusWidget());
		m_myFinNal = NULL;
	}
	if (qobject_cast<QMyKontenPlan*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyKontenPlan>((QMyKontenPlan*)qApp->focusWidget());
		m_mykontenplan = NULL;
	}
	if (qobject_cast<QCenovnik*>(qApp->focusWidget()))
	{
		deleteMyWidget<QCenovnik>((QCenovnik*)qApp->focusWidget());
		m_myCenovnik = NULL;
	}
	if (qobject_cast<QMyProdPovratnica*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyProdPovratnica>((QMyProdPovratnica*)qApp->focusWidget());
		m_prodPovratnica = NULL;
	}

	if (qobject_cast<QMyProdNivelacija*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyProdNivelacija>((QMyProdNivelacija*)qApp->focusWidget());
		m_prodNivelacija = NULL;
	}

	if (qobject_cast<QMyProdSmetka*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyProdSmetka>((QMyProdSmetka*)qApp->focusWidget());
		m_prodsmetka = NULL;
	}

	if (qobject_cast<QMyETM*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyETM>((QMyETM*)qApp->focusWidget());
		m_etm = NULL;
	}

	if (qobject_cast<QLagerProdavnica*>(qApp->focusWidget()))
	{
		deleteMyWidget<QLagerProdavnica>((QLagerProdavnica*)qApp->focusWidget());
		m_myLagerProdavnica = NULL;
	}

	if (qobject_cast<QMyNivelacija*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyNivelacija>((QMyNivelacija*)qApp->focusWidget());
		m_myNivelacija = NULL;
	}
	if (qobject_cast<QMySmetki*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMySmetki>((QMySmetki*)qApp->focusWidget());
		m_mysmetki = NULL;
	}
	if (qobject_cast<QMyPLTM*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyPLTM>((QMyPLTM*)qApp->focusWidget());
		m_pltm = NULL;
	}
	if (qobject_cast<QAnalitikaArtikli*>(qApp->focusWidget()))
	{
		deleteMyWidget<QAnalitikaArtikli>((QAnalitikaArtikli*)qApp->focusWidget());
		m_analitikaArtikli = NULL;
	}
	if (qobject_cast<QAnalitikaKomintenti*>(qApp->focusWidget()))
	{
		deleteMyWidget<QAnalitikaKomintenti>((QAnalitikaKomintenti*)qApp->focusWidget());
		m_analitikaKomintenti = NULL;
	}

	if (qobject_cast<QMyNormativ*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyNormativ>((QMyNormativ*)qApp->focusWidget());
		m_mynormativ = NULL;
	}
	if (qobject_cast<QMyNaracki*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyNaracki>((QMyNaracki*)qApp->focusWidget());
		m_mynaracki = NULL;
	}

	if (qobject_cast<QMyNalog*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyNalog>((QMyNalog*)qApp->focusWidget());
		m_mynalog = NULL;
	}

	if (qobject_cast<QDnevenpromet*>(qApp->focusWidget()))
	{
		deleteMyWidget<QDnevenpromet>((QDnevenpromet*)qApp->focusWidget());
		m_dnevenpromet = NULL;
	}

	if (qobject_cast<QMyIzjava*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyIzjava>((QMyIzjava*)qApp->focusWidget());
		m_myizjava = NULL;
	}

    if (qobject_cast<QKomintentiAnalitika*>(qApp->focusWidget()))
    {
        deleteMyWidget<QKomintentiAnalitika>((QKomintentiAnalitika*)qApp->focusWidget());
        m_mykomintenti_analitika = NULL;
    }

    if (qobject_cast<QMyArtikli*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyArtikli>((QMyArtikli*)qApp->focusWidget());
		m_myartikli = NULL;
	}
	if (qobject_cast<QMyKomintenti*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyKomintenti>((QMyKomintenti*)qApp->focusWidget());
		m_mykomintenti = NULL;
	}
    if (qobject_cast<QLager*>(qApp->focusWidget()))
    {
        deleteMyWidget<QLager>((QLager*)qApp->focusWidget());
        m_mylager = NULL;
    }
    if (qobject_cast<QLSearch*>(qApp->focusWidget()))
    {
        deleteMyWidget<QLSearch>((QLSearch*)qApp->focusWidget());
        m_myLSearch = NULL;
    }
    if (qobject_cast<QMyIspratnici*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyIspratnici>((QMyIspratnici*)qApp->focusWidget());
		m_myispratnici = NULL;
	}
	if (qobject_cast<QMyPriemnica*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyPriemnica>((QMyPriemnica*)qApp->focusWidget());
		m_mypriemnici = NULL;
	}

	if (qobject_cast<QMyKalkulacija*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyKalkulacija>((QMyKalkulacija*)qApp->focusWidget());
		m_mykalkulacija = NULL;
	}

	if (qobject_cast<QMyPovratnica*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyPovratnica>((QMyPovratnica*)qApp->focusWidget());
		m_mypovratnica = NULL;
	}
	if (qobject_cast<QMyFakturi*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyFakturi>((QMyFakturi*)qApp->focusWidget());
		m_myfaktura = NULL;
	}
    if (qobject_cast<QFakturiVlezni*>(qApp->focusWidget()))
    {
        deleteMyWidget<QFakturiVlezni>((QFakturiVlezni*)qApp->focusWidget());
        m_myfakturavlezna = NULL;
    }
	if (qobject_cast<QMyDdv*>(qApp->focusWidget()))
	{
		deleteMyWidget<QMyDdv>((QMyDdv*)qApp->focusWidget());
		m_myddv = NULL;
	}
    if (qobject_cast<QMyProFakturi*>(qApp->focusWidget()))
    {
        deleteMyWidget<QMyProFakturi>((QMyProFakturi*)qApp->focusWidget());
        m_myprofakturi = NULL;
    }
    if (qobject_cast<QMyKasa*>(qApp->focusWidget()))
    {
        deleteMyWidget<QMyKasa>((QMyKasa*)qApp->focusWidget());
        m_mykasa = NULL;
    }
    if (qobject_cast<QMyBanki*>(qApp->focusWidget()))
    {
        deleteMyWidget<QMyBanki>((QMyBanki*)qApp->focusWidget());
        m_mybanki = NULL;
    }
    if (qobject_cast<QMyIzvod*>(qApp->focusWidget()))
    {
        deleteMyWidget<QMyIzvod>((QMyIzvod*)qApp->focusWidget());
        m_myizvod = NULL;
    }
    if (qobject_cast<QIzvestai*>(qApp->focusWidget()))
    {
        deleteMyWidget<QIzvestai>((QIzvestai*)qApp->focusWidget());
        m_myizvestai = NULL;
    }
}

void sterna::connectToDatabase()
{
	// create database 
	QSqlDatabase db = QSqlDatabase::addDatabase("QODBC"); 
	db.setDatabaseName("office2015new");

	if (!db.open()) 
	{
		QMessageBox msgBox;
		msgBox.setText("Connection with database failed !!!");
		msgBox.setStandardButtons(QMessageBox::Ok);
		msgBox.setDefaultButton(QMessageBox::Ok);
		int ret = msgBox.exec();	
		QTimer::singleShot(1, qApp, SLOT(quit()));
	}
	QSqlError a = db.lastError();
// 	QHSGUserForm * uf = new QHSGUserForm((QDialog*)this);
// 	uf->setModal(true);
// 	if(uf->exec() == QDialog::Accepted)
// 	{
// 		m_userInfo = uf->m_Info;
// 	}
// 	else
// 	{
// 		QTimer::singleShot(0, qApp, SLOT(quit()));
// 	}

    updateMeniItems(true);
	//QTimer::singleShot(250, qApp, SLOT(quit()));
}

void sterna::updateMeniItems(bool status)
{

#ifdef _OFFICE_MANAGER
	ui.action_KomintentiLista->setVisible(true);
	ui.action_MyArtikli->setVisible(true);
	ui.actionAnalitikaArtikli->setVisible(true);
	ui.actionAnalitikaKomintent->setVisible(true);
	ui.actionAnalitikaKomintenti->setVisible(true);
	ui.actionBanki->setVisible(true);
	ui.actionDDV->setVisible(false);
	ui.actionDnevenPromet->setVisible(true);
	ui.actionIzjava->setVisible(false);
	ui.actionIzvestai->setVisible(true);
	ui.actionIzvodi->setVisible(true);
	ui.actionKalkulacii->setVisible(true);
	ui.actionKasi->setVisible(false);
	ui.actionLager->setVisible(true);
	ui.actionLSearch->setVisible(true);
	ui.actionMyFakturi->setVisible(true);
	ui.actionMyFakturiVlezni->setVisible(true);
	ui.actionMyIspratnici->setVisible(true);
	ui.actionMyPovratnica->setVisible(true);
	ui.actionMyPriemnici->setVisible(true);
	ui.actionNalog->setVisible(true);
	ui.actionNaracka->setVisible(true);
	ui.actionNormativ->setVisible(true);
	ui.actionPreview->setVisible(true);
	ui.actionPrinter->setVisible(true);
	ui.actionProFaktura->setVisible(true);
	ui.mainToolBar->setVisible(true);
	ui.toolBar->setVisible(true);
	ui.toolBar_2->setVisible(true);
	ui.toolBar_3->setVisible(true);
	ui.toolBar_4->setVisible(true);

#endif
	
#ifdef _MAGACIN
	ui.action_KomintentiLista->setVisible(true);
	ui.action_MyArtikli->setVisible(true);
	ui.actionAnalitikaArtikli->setVisible(true);
	ui.actionAnalitikaKomintent->setVisible(true);
	ui.actionAnalitikaKomintenti->setVisible(true);
	ui.actionBanki->setVisible(false);
	ui.actionDDV->setVisible(false);
	ui.actionDnevenPromet->setVisible(false);
	ui.actionIzjava->setVisible(false);
	ui.actionIzvestai->setVisible(false);
	ui.actionIzvodi->setVisible(false);
	ui.actionKalkulacii->setVisible(false);
	ui.actionKasi->setVisible(false);
	ui.actionLager->setVisible(true);
	ui.actionLSearch->setVisible(true);
	ui.actionMyFakturi->setVisible(false);
	ui.actionMyFakturiVlezni->setVisible(false);
	ui.actionMyIspratnici->setVisible(true);
	ui.actionMyPovratnica->setVisible(true);
	ui.actionMyPriemnici->setVisible(true);
	ui.actionNalog->setVisible(true);
	ui.actionNaracka->setVisible(true);
	ui.actionNormativ->setVisible(true);
	ui.actionPreview->setVisible(true);
	ui.actionPrinter->setVisible(true);
	ui.actionProFaktura->setVisible(false);
	ui.mainToolBar->setVisible(true);
	ui.toolBar->setVisible(true);
	ui.toolBar_2->setVisible(false);
	ui.toolBar_3->setVisible(false);
	ui.toolBar_4->setVisible(true);
#endif

#ifdef _PRODAVNICI
	ui.action_KomintentiLista->setVisible(true);
	ui.action_MyArtikli->setVisible(true);
	ui.actionAnalitikaArtikli->setVisible(false);
	ui.actionAnalitikaKomintent->setVisible(false);
	ui.actionAnalitikaKomintenti->setVisible(false);
	ui.actionBanki->setVisible(false);
	ui.actionDDV->setVisible(true);
	ui.actionDnevenPromet->setVisible(false);
	ui.actionIzjava->setVisible(false);
	ui.actionIzvestai->setVisible(false);
	ui.actionIzvodi->setVisible(false);
	ui.actionKalkulacii->setVisible(false);
	ui.actionKasi->setVisible(true);
	ui.actionLager->setVisible(true);
	ui.actionLSearch->setVisible(true);
	ui.actionMyFakturi->setVisible(false);
	ui.actionMyFakturiVlezni->setVisible(false);
	ui.actionMyIspratnici->setVisible(false);
	ui.actionMyPovratnica->setVisible(false);
	ui.actionMyPriemnici->setVisible(false);
	ui.actionNalog->setVisible(false);
	ui.actionNaracka->setVisible(true);
	ui.actionNormativ->setVisible(false);
	ui.actionPreview->setVisible(true);
	ui.actionPrinter->setVisible(true);
	ui.actionProFaktura->setVisible(true);
	ui.mainToolBar->setVisible(true);
	ui.toolBar->setVisible(true);
	ui.toolBar_2->setVisible(true);
	ui.toolBar_3->setVisible(false);
	ui.toolBar_4->setVisible(true);
#endif


}


void sterna::on_actionDDV_triggered()
{
	m_myddv = showMyWidget<QMyDdv, QWidget, QWidget>(m_myddv, moi_ddv, ui.centralWidget, NULL);
}

void sterna::filePrintPreview(int orient)
{
    int m_aleft = 0;
    int m_atop = 0;
    int m_aright = 0;
    int m_abottom = 0;
    QPrinter printer(QPrinter::HighResolution);
	printer.setPrintRange(QPrinter::Selection);
	if (orient)
    {
        printer.setOrientation(QPrinter::Landscape);
        m_pageWidth = printer.pageRect().height();  //4961
        m_pageHeight = printer.pageRect().width(); //7016
        m_pageHeightScale = (float)printer.pageRect().height() / 4961.0f;
        m_pageWidthScale = (float)printer.pageRect().width() /7016.0f;
    }
    else
    {
        printer.setOrientation(QPrinter::Portrait);
        m_pageWidth = printer.pageRect().width();  //4961
        m_pageHeight = printer.pageRect().height(); //7016
        m_pageWidthScale = (float)printer.pageRect().width() / 4961.0f;
        m_pageHeightScale = (float)printer.pageRect().height() /7016.0f;
    }

    printer.setPageMargins(m_aleft,m_atop,m_aright,m_abottom,QPrinter::Millimeter);
	printPreview(&printer);
}

void sterna::filePreview(int orient)
{
	int m_aleft = 0;
	int m_atop = 0;
	int m_aright = 0;
	int m_abottom = 0;
	QPrinter printer(QPrinter::HighResolution);
	printer.setPrintRange(QPrinter::PageRange);
    if (orient)
    {
        printer.setOrientation(QPrinter::Landscape);
        m_pageWidth = printer.pageRect().height();  //4961
        m_pageHeight = printer.pageRect().width(); //7016
        m_pageHeightScale = (float)printer.pageRect().height() / 4961.0f;
        m_pageWidthScale = (float)printer.pageRect().width() /7016.0f;
    }
    else
    {
        printer.setOrientation(QPrinter::Portrait);
        m_pageWidth = printer.pageRect().width();  //4961
        m_pageHeight = printer.pageRect().height(); //7016
        m_pageWidthScale = (float)printer.pageRect().width() / 4961.0f;
        m_pageHeightScale = (float)printer.pageRect().height() /7016.0f;
    }

    printer.setPageMargins(m_aleft,m_atop,m_aright,m_abottom,QPrinter::Millimeter);
	QPrintPreviewDialog preview(&printer, this);
	preview.setWindowFlags(Qt::Window);
	connect(&preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printPreview(QPrinter *)));
	preview.resize(width(), height());
	preview.exec();
}

void sterna::printPreview(QPrinter *printer)
{

    QPainter painter( printer );
    painter.setPen( Qt::black );

    m_left->getSelection();
	switch (m_selectedPrint)
	{
	case SV_ART: drawArtikliLista(printer, painter); break;
	case SV_KOM: drawKomintentiLista(painter); break;
	case SV_ISP: drawIspratnica(printer, painter); break;
    case SV_ISP_MALA: drawIspratnicaMala(printer, painter); break;
	case SV_TVL: drawTovarenList(printer, painter); break;
	case SV_PRI: drawPriemnica(printer, painter); break;
	case SV_POV: break;
	case SV_FKT: drawFaktura(printer, painter); break;
	case SV_DDV: break;
	case SV_PFKT: drawProFaktura(printer, painter); break;
	case SV_KAS: break;
	case SV_BNK: break;
	case SV_IZV: break;
	case SV_IZVES: break;
	case SV_LGR: drawLagerLista(printer, painter); break;
	case SV_IZJ: drawIzjava(printer, painter); break;
	case SV_DNVIZV: drawDnevenIzvestaj(printer, painter); break;

	case SV_ANA: drawAnalitikaArtikli(printer, painter); break;
	case SV_ANK: drawAnalitikaKomintenti(printer, painter); break;
	case SV_PLTM: drawPLTM(printer, painter); break;
	case SV_PPOVR: drawProdPovratnica(printer, painter); break;
	case SV_PSMTK: drawProdSmetka(printer, painter); break;
	}
}

void sterna::drawHeader(QPainter& painter)
{
    QFont f;
    QPainterPath path;
    f.setPointSize(18);
    painter.setFont(f);
    painter.drawText(relX(30), relY(100), trUtf8("Фактура бр:"));
    f.setPointSize(8);
    painter.setFont(f);
    painter.drawText(relX(20), relY(110), trUtf8("Врз основа на Ваше барање број _____________ од ____________________ Ви се испорачани долунаведените материјали:"));
    QBrush b;
    painter.fillRect(relX(20), relY(120), relX(170), relY(5), QColor(0, 200, 5));
    path.addRect(relX(20), relY(120), relX(170), relY(5));
    path.addRect(relX(20), relY(125), relX(170), relY(5));
    path.addRect(relX(20), relY(130), relX(170), relY(5));
	path.addRect(relX(20), relY(135), relX(170), relY(5));
	path.addRect(relX(20), relY(140), relX(170), relY(5));
	path.addRect(relX(20), relY(145), relX(170), relY(5));
	path.addRect(relX(20), relY(150), relX(170), relY(5));
	path.addRect(relX(20), relY(155), relX(170), relY(5));
	path.addRect(relX(20), relY(160), relX(170), relY(5));
	path.addRect(relX(20), relY(165), relX(170), relY(5));
    path.addRect(relX(20), relY(170), relX(170), relY(5));
    path.addRect(relX(20), relY(170), relX(170), relY(5));
    path.addRect(relX(20), relY(175), relX(170), relY(5));
    path.addRect(relX(20), relY(180), relX(170), relY(5));
    path.addRect(relX(20), relY(185), relX(170), relY(5));
    path.addRect(relX(20), relY(190), relX(170), relY(5));
    path.addRect(relX(20), relY(195), relX(170), relY(5));
    path.addRect(relX(20), relY(200), relX(170), relY(5));
    path.addRect(relX(20), relY(205), relX(170), relY(5));
    path.addRect(relX(20), relY(210), relX(170), relY(5));
    path.addRect(relX(20), relY(215), relX(170), relY(5));

    path.moveTo(relX(21),relY(120));
    path.lineTo(relX(21),relY(220));
    path.moveTo(relX(30),relY(120));
    path.lineTo(relX(30),relY(220));
    path.moveTo(relX(85),relY(120));
    path.lineTo(relX(85),relY(220));
    path.moveTo(relX(100),relY(120));
    path.lineTo(relX(100),relY(220));
    path.moveTo(relX(115),relY(120));
    path.lineTo(relX(115),relY(220));
    path.moveTo(relX(130),relY(120));
    path.lineTo(relX(130),relY(220));
    path.moveTo(relX(160),relY(120));
    path.lineTo(relX(160),relY(220));

    f.setPointSize(8);
    painter.setFont(f);
    painter.drawText(relX(22), relY(124), trUtf8("Рб."));
    painter.drawText(relX(32), relY(124), trUtf8("ОПИС"));
    painter.drawText(relX(87), relY(124), trUtf8("Едм"));
    painter.drawText(relX(102), relY(124), trUtf8("Кол."));
    painter.drawText(relX(117), relY(124), trUtf8("Цена"));
    painter.drawText(relX(132), relY(124), trUtf8("ДДВ"));
    painter.drawText(relX(162), relY(124), trUtf8("Износ со ДДВ"));
    painter.drawRoundedRect(relX(100), relY(45), relX(90), relY(45), relX(3), relY(3), Qt::AbsoluteSize );
    path.moveTo(relX(20),relY(260));
    path.lineTo(relX(70),relY(260));
    path.moveTo(relX(140),relY(260));
    path.lineTo(relX(190),relY(260));
    painter.drawText(relX(25), relY(265), trUtf8("Фактурирал"));
    painter.drawText(relX(145), relY(265), trUtf8("Директор"));
    painter.drawPath(path);
    painter.drawRoundedRect(relX(20), relY(117), relX(170), relY(106), relX(3), relY(3), Qt::AbsoluteSize );

}

void sterna::drawFooter(QPainter& painter)
{
}

int sterna::relX(double x)
{
    return (int) (m_pageWidthScale * 4961 * x * 10 / 2100); //mm 210
}

int sterna::relY(double y)
{
    return (int) (m_pageHeightScale * 7016 *y * 10/ 2970); //mm  297
}

void sterna::drawFaktura(QPrinter *printer, QPainter& painter)
{
	QLocale loc;
    int maxpage = 1;
	float suma = 0.0f;
	float ddv = 0.0f;
	float sumaDDV = 0.0f;

	
	QFont f;
	for( int page=0; page<maxpage; page++)
	{

    QFont f;
    QPainterPath path;

    f.setPointSize(18);
    painter.setFont(f);
    painter.drawText(relX(160), relY(70), relX(40), relY(60), Qt::AlignRight, trUtf8("Фактура"));
    f.setPointSize(8);

    QStringList modelIspratnicaInfo = m_myfaktura->getIspratnicaInfo();

    painter.setFont(f);
    painter.drawText(relX(160), relY(78), relX(40), relY(65), Qt::AlignRight, trUtf8("Сериски Број: ") + modelIspratnicaInfo.at(4));
    painter.drawText(relX(160), relY(81), relX(40), relY(70), Qt::AlignRight, trUtf8("Датум: ") + modelIspratnicaInfo.at(3));
    painter.drawText(relX(160), relY(84), relX(40), relY(75), Qt::AlignRight, trUtf8("Валута: ") + modelIspratnicaInfo.at(3));
    //         painter.drawRoundedRect(relX(20), relY(55), relX(80), relY(30), relX(3), relY(3), Qt::AbsoluteSize );
    painter.drawText(relX(25), relY(70), trUtf8("До:"));


    painter.drawText(relX(25), relY(75), modelIspratnicaInfo.at(0));
    painter.drawText(relX(25), relY(80), modelIspratnicaInfo.at(1));
    painter.drawText(relX(25), relY(85), modelIspratnicaInfo.at(2));

	painter.drawRoundedRect(relX(10), relY(90), relX(190), relY(145), relX(2), relY(2), Qt::AbsoluteSize );
	path.moveTo(relX(10),relY(95));
	path.lineTo(relX(200),relY(95));

	path.moveTo(relX(15),relY(90));
	path.lineTo(relX(15),relY(235));

	path.moveTo(relX(70),relY(90));
	path.lineTo(relX(70),relY(235));

	path.moveTo(relX(80),relY(90));
	path.lineTo(relX(80),relY(235));

	path.moveTo(relX(92),relY(90));
	path.lineTo(relX(92),relY(235));

	path.moveTo(relX(110),relY(90));
	path.lineTo(relX(110),relY(235));

	path.moveTo(relX(120),relY(90));
	path.lineTo(relX(120),relY(235));

	path.moveTo(relX(140),relY(90));
	path.lineTo(relX(140),relY(235));

	path.moveTo(relX(150),relY(90));
	path.lineTo(relX(150),relY(235));

	path.moveTo(relX(175),relY(90));
	path.lineTo(relX(175),relY(235));

	painter.drawText(relX(11), relY(94), trUtf8("Рб."));
	painter.drawText(relX(17), relY(94), trUtf8("Опис на артикал - услуга"));
	painter.drawText(relX(72), relY(94), trUtf8("Кол."));
	painter.drawText(relX(82), relY(94), trUtf8("Едм."));
	painter.drawText(relX(95), relY(94), trUtf8("Цена"));
	painter.drawText(relX(111), relY(94), trUtf8("Раб.%"));
	painter.drawText(relX(122), relY(94), trUtf8("Цена/рабат"));
	painter.drawText(relX(141), relY(94), trUtf8("ДДВ%"));
	painter.drawText(relX(152), relY(94), trUtf8("ДДВ Износ"));
	painter.drawText(relX(177), relY(94), trUtf8("Вкупно"));

	path.moveTo(relX(10),relY(259));
	path.lineTo(relX(70),relY(259));
	path.moveTo(relX(140),relY(259));
	path.lineTo(relX(190),relY(259));
    painter.drawText(relX(11), relY(262), trUtf8("Фактурирал"));
    painter.drawText(relX(145), relY(262), trUtf8("Примил"));
    path.moveTo(relX(10),relY(247));
	path.lineTo(relX(200),relY(247));

	painter.drawPath(path);
	
	QStandardItemModel * modelFaktura2 = m_myfaktura->getModel2();

	if (modelFaktura2)
	{
		int maxRowPage = 21;
		maxpage = modelFaktura2->rowCount() / (maxRowPage + 1) + 1;
		int pagefrom = page * maxRowPage;
		int pageto = (page + 1) * maxRowPage < modelFaktura2->rowCount() ? (page + 1) * maxRowPage : modelFaktura2->rowCount();

		for (int row = pagefrom; row < pageto; row++)
		{
			for (int col = 0; col < 10; col++)
			{
				switch (col)
				{
				case 0: painter.drawText(relX(11), relY(100 + 6 * (row - pagefrom)), relX(4), relY(9), Qt::AlignLeft, QString::number(row + 1, 10));break;
				case 1: 
// 					f.setPointSize(7);
// 					painter.setFont(f);
					painter.drawText(relX(16), relY(100 + 6 * (row - pagefrom)), relX(54), relY(9), Qt::AlignLeft, modelFaktura2->item(row, col + 1)->text());
// 					f.setPointSize(8);
// 					painter.setFont(f);
					break;
				case 2: painter.drawText(relX(71), relY(100 + 6 * (row - pagefrom)), relX(9), relY(9), Qt::AlignRight, modelFaktura2->item(row, col + 1)->text());break;
				case 3: painter.drawText(relX(81), relY(100 + 6 * (row - pagefrom)), relX(14), relY(9), Qt::AlignLeft,  modelFaktura2->item(row, col + 1)->text());break;
				case 4: painter.drawText(relX(96), relY(100 + 6 * (row - pagefrom)), relX(14), relY(9), Qt::AlignRight,  modelFaktura2->item(row, col + 1)->text());break;
				case 5: painter.drawText(relX(111), relY(100 + 6 * (row - pagefrom)), relX(9), relY(9), Qt::AlignRight,  modelFaktura2->item(row, col + 1)->text());break;
				case 6: painter.drawText(relX(121), relY(100 + 6 * (row - pagefrom)), relX(19), relY(9), Qt::AlignRight,  modelFaktura2->item(row, col + 1)->text());
					break;
				case 7: painter.drawText(relX(141), relY(100 + 6 * (row - pagefrom)), relX(9), relY(9), Qt::AlignRight,  modelFaktura2->item(row, col + 1)->text());break;
				case 8: painter.drawText(relX(152), relY(100 + 6 * (row - pagefrom)), relX(23), relY(15), Qt::AlignRight,  modelFaktura2->item(row, col + 1)->text());
					ddv =ddv + loc.toFloat(modelFaktura2->item(row, col + 1)->text());
					break;
				case 9: painter.drawText(relX(177), relY(100 + 6 * (row - pagefrom)), relX(23), relY(15), Qt::AlignRight,  modelFaktura2->item(row, col + 1)->text());
					sumaDDV =sumaDDV + loc.toFloat(modelFaktura2->item(row, col + 1)->text());
					break;
				}
			}
		}
	}
	if( page < maxpage-1 )
		printer->newPage();
	}
	
	painter.drawText(relX(130), relY(235), relX(40), relY(10), Qt::AlignRight, trUtf8("Вкупен Износ без ДДВ"));
	painter.drawText(relX(170), relY(235), relX(30), relY(10), Qt::AlignRight, loc.toString( sumaDDV - ddv, 'f', 2) + trUtf8("  ден."));

	painter.drawText(relX(130), relY(239), relX(40), relY(10), Qt::AlignRight, trUtf8("Вкупен ДДВ"));
	painter.drawText(relX(170), relY(239), relX(30), relY(10), Qt::AlignRight, loc.toString( ddv, 'f', 2) + trUtf8("  ден."));

	painter.drawText(relX(130), relY(243), relX(40), relY(10), Qt::AlignRight, trUtf8("Вкупно за наплата денари"));
	painter.drawText(relX(170), relY(243), relX(30), relY(10), Qt::AlignRight, loc.toString( sumaDDV, 'f', 2) + trUtf8("  ден."));

// 	painter.drawText(relX(15), relY(280), trUtf8("Фактурирал"));

	f.setPointSize(7);
	painter.setFont(f);
	int p = int(sumaDDV + 0.5f);
	QString t = convertIntToText(p);
	painter.drawText(relX(10), relY(247), relX(120), relY(6), Qt::AlignLeft,t);


}

void sterna::drawProFaktura(QPrinter *printer, QPainter& painter)
{
	QLocale loc;
	int maxpage = 1;
	float suma = 0.0f;
	float ddv = 0.0f;
	float sumaDDV = 0.0f;


	QFont f;
	for( int page=0; page<maxpage; page++)
	{
        QFont f;
        QPainterPath path;

        f.setPointSize(18);
        painter.setFont(f);
        painter.drawText(relX(160), relY(70), relX(40), relY(60), Qt::AlignRight, trUtf8("Про-Фактура"));
        f.setPointSize(8);

        QStringList modelIspratnicaInfo = m_myprofakturi->getIspratnicaInfo();

        painter.setFont(f);
        painter.drawText(relX(160), relY(78), relX(40), relY(65), Qt::AlignRight, trUtf8("Сериски Број: ") + modelIspratnicaInfo.at(4));
        painter.drawText(relX(160), relY(81), relX(40), relY(70), Qt::AlignRight, trUtf8("Датум: ") + modelIspratnicaInfo.at(3));
        painter.drawText(relX(160), relY(84), relX(40), relY(75), Qt::AlignRight, trUtf8("Валута: ") + modelIspratnicaInfo.at(3));
        //         painter.drawRoundedRect(relX(20), relY(55), relX(80), relY(30), relX(3), relY(3), Qt::AbsoluteSize );
        painter.drawText(relX(25), relY(70), trUtf8("До:"));


        painter.drawText(relX(25), relY(75), modelIspratnicaInfo.at(0));
        painter.drawText(relX(25), relY(80), modelIspratnicaInfo.at(1));
        painter.drawText(relX(25), relY(85), modelIspratnicaInfo.at(2));


		painter.drawRoundedRect(relX(10), relY(90), relX(190), relY(145), relX(2), relY(2), Qt::AbsoluteSize );
		path.moveTo(relX(10),relY(95));
		path.lineTo(relX(200),relY(95));

		path.moveTo(relX(15),relY(90));
		path.lineTo(relX(15),relY(235));

		path.moveTo(relX(70),relY(90));
		path.lineTo(relX(70),relY(235));

		path.moveTo(relX(80),relY(90));
		path.lineTo(relX(80),relY(235));

		path.moveTo(relX(92),relY(90));
		path.lineTo(relX(92),relY(235));

		path.moveTo(relX(110),relY(90));
		path.lineTo(relX(110),relY(235));

		path.moveTo(relX(120),relY(90));
		path.lineTo(relX(120),relY(235));

		path.moveTo(relX(140),relY(90));
		path.lineTo(relX(140),relY(235));

		path.moveTo(relX(150),relY(90));
		path.lineTo(relX(150),relY(235));

		path.moveTo(relX(175),relY(90));
		path.lineTo(relX(175),relY(235));

		painter.drawText(relX(11), relY(94), trUtf8("Рб."));
		painter.drawText(relX(17), relY(94), trUtf8("Опис на артикал - услуга"));
		painter.drawText(relX(72), relY(94), trUtf8("Кол."));
		painter.drawText(relX(82), relY(94), trUtf8("Едм."));
		painter.drawText(relX(95), relY(94), trUtf8("Цена"));
		painter.drawText(relX(111), relY(94), trUtf8("Раб.%"));
		painter.drawText(relX(122), relY(94), trUtf8("Цена/рабат"));
		painter.drawText(relX(141), relY(94), trUtf8("ДДВ%"));
		painter.drawText(relX(152), relY(94), trUtf8("ДДВ Износ"));
		painter.drawText(relX(177), relY(94), trUtf8("Вкупно"));

		path.moveTo(relX(10),relY(255));
		path.lineTo(relX(70),relY(255));
		path.moveTo(relX(140),relY(255));
		path.lineTo(relX(190),relY(255));
		painter.drawText(relX(11), relY(258), trUtf8("Фактурирал"));
		painter.drawText(relX(145), relY(258), trUtf8("Примил"));
		path.moveTo(relX(10),relY(243));
		path.lineTo(relX(200),relY(243));
		
        painter.drawPath(path);

		QStandardItemModel * modelFaktura2 = m_myprofakturi->getModel2();

		if (modelFaktura2)
		{
			int maxRowPage = 21;
			maxpage = modelFaktura2->rowCount() / (maxRowPage + 1) + 1;
			int pagefrom = page * maxRowPage;
			int pageto = (page + 1) * maxRowPage < modelFaktura2->rowCount() ? (page + 1) * maxRowPage : modelFaktura2->rowCount();

			for (int row = pagefrom; row < pageto; row++)
			{
				for (int col = 0; col < 10; col++)
				{
					switch (col)
					{
					case 0: painter.drawText(relX(11), relY(100 + 6 * (row - pagefrom)), relX(4), relY(9), Qt::AlignLeft, QString::number(row + 1, 10));break;
					case 1: 
						// 					f.setPointSize(7);
						// 					painter.setFont(f);
						painter.drawText(relX(16), relY(100 + 6 * (row - pagefrom)), relX(54), relY(9), Qt::AlignLeft, modelFaktura2->item(row, col + 1)->text());
						// 					f.setPointSize(8);
						// 					painter.setFont(f);
						break;
					case 2: painter.drawText(relX(71), relY(100 + 6 * (row - pagefrom)), relX(9), relY(9), Qt::AlignRight, modelFaktura2->item(row, col + 1)->text());break;
					case 3: painter.drawText(relX(81), relY(100 + 6 * (row - pagefrom)), relX(14), relY(9), Qt::AlignLeft,  modelFaktura2->item(row, col + 1)->text());break;
					case 4: painter.drawText(relX(96), relY(100 + 6 * (row - pagefrom)), relX(14), relY(9), Qt::AlignRight,  modelFaktura2->item(row, col + 1)->text());break;
					case 5: painter.drawText(relX(111), relY(100 + 6 * (row - pagefrom)), relX(9), relY(9), Qt::AlignRight,  modelFaktura2->item(row, col + 1)->text());break;
					case 6: painter.drawText(relX(121), relY(100 + 6 * (row - pagefrom)), relX(19), relY(9), Qt::AlignRight,  modelFaktura2->item(row, col + 1)->text());
						break;
					case 7: painter.drawText(relX(141), relY(100 + 6 * (row - pagefrom)), relX(9), relY(9), Qt::AlignRight,  modelFaktura2->item(row, col + 1)->text());break;
					case 8: painter.drawText(relX(152), relY(100 + 6 * (row - pagefrom)), relX(23), relY(15), Qt::AlignRight,  modelFaktura2->item(row, col + 1)->text());
						ddv =ddv + loc.toFloat(modelFaktura2->item(row, col + 1)->text());
						break;
					case 9: painter.drawText(relX(177), relY(100 + 6 * (row - pagefrom)), relX(23), relY(15), Qt::AlignRight,  modelFaktura2->item(row, col + 1)->text());
						sumaDDV =sumaDDV + loc.toFloat(modelFaktura2->item(row, col + 1)->text());
						break;
					}
				}
			}
		}
		if( page < maxpage-1 )
			printer->newPage();
	}

    painter.drawText(relX(130), relY(235), relX(40), relY(10), Qt::AlignRight, trUtf8("Вкупен ДДВ"));
    painter.drawText(relX(170), relY(235), relX(30), relY(10), Qt::AlignRight, loc.toString( ddv, 'f', 2) + trUtf8("  ден."));

    painter.drawText(relX(130), relY(239), relX(40), relY(10), Qt::AlignRight, trUtf8("Вкупно за наплата денари"));
    painter.drawText(relX(170), relY(239), relX(30), relY(10), Qt::AlignRight, loc.toString( sumaDDV, 'f', 2) + trUtf8("  ден."));

	// 	painter.drawText(relX(15), relY(280), trUtf8("Фактурирал"));

	f.setPointSize(7);
	painter.setFont(f);
	int p = int(sumaDDV + 0.5f);
	QString t = convertIntToText(p);
	painter.drawText(relX(10), relY(243), relX(120), relY(6), Qt::AlignLeft,t);
}

// void sterna::drawIspratnica(QPrinter *printer, QPainter& painter)
// {
//   	QLocale loc;
//     int maxpage = 1;
//     for( int page=0; page<maxpage; page++)
//     {
//     QFont f;
// 	QPainterPath path;
// 
// 	f.setPointSize(12);
// 	painter.setFont(f);
// 	painter.drawText(relX(0), relY(3), relX(210), relY(6), Qt::AlignCenter, moi_firma_info1);
// 	f.setPointSize(10);
// 	painter.setFont(f);
// 	painter.drawText(relX(0), relY(6), relX(210), relY(9), Qt::AlignCenter, moi_firma_info2);
// 
//     QPixmap image1(moi_logo);
//     painter.drawPixmap(relX(90), relY(20), relX(30), relX(20), image1);
// 
// 	f.setPointSize(18);
// 	painter.setFont(f);
// 	painter.drawText(relX(160), relY(50), relX(40), relY(60), Qt::AlignRight, trUtf8("Испратница"));
// 	f.setPointSize(8);
// 
//     QStringList modelIspratnicaInfo = m_myispratnici->getIspratnicaInfo();
//     
//     painter.setFont(f);
// 	painter.drawText(relX(160), relY(35), relX(40), relY(40), Qt::AlignRight, moi_firma_tel);
// 	painter.drawText(relX(160), relY(40), relX(40), relY(45), Qt::AlignRight, moi_firma_email);
// 	painter.drawText(relX(150), relY(45), relX(50), relY(50), Qt::AlignRight, moi_firma_web);
// 	painter.drawText(relX(160), relY(60), relX(40), relY(65), Qt::AlignRight, trUtf8("Сериски Број: ") + modelIspratnicaInfo.at(4));
// 	painter.drawText(relX(160), relY(65), relX(40), relY(70), Qt::AlignRight, trUtf8("Датум: ") + modelIspratnicaInfo.at(3));
// 	painter.drawText(relX(160), relY(70), relX(40), relY(75), Qt::AlignRight, trUtf8("Валута: ") + modelIspratnicaInfo.at(3));
// 	painter.drawRoundedRect(relX(20), relY(55), relX(80), relY(30), relX(3), relY(3), Qt::AbsoluteSize );
// 	painter.drawText(relX(25), relY(60), trUtf8("До:"));
// 
// 
//     painter.drawText(relX(25), relY(65), modelIspratnicaInfo.at(0));
//     painter.drawText(relX(25), relY(70), modelIspratnicaInfo.at(1));
//     painter.drawText(relX(25), relY(75), modelIspratnicaInfo.at(2));
// 
//     painter.drawText(relX(20), relY(35), relX(60), relY(40), Qt::AlignLeft, moi_firma_banka1);
// 	painter.drawText(relX(20), relY(40), relX(60), relY(45), Qt::AlignLeft, moi_firma_banka2);
// 	painter.drawText(relX(20), relY(45), relX(60), relY(50), Qt::AlignLeft, moi_firma_edb);
// 
// 	painter.drawRoundedRect(relX(20), relY(90), relX(180), relY(140), relX(2), relY(2), Qt::AbsoluteSize );
// 	path.moveTo(relX(20),relY(95));
// 	path.lineTo(relX(200),relY(95));
// 
// 	path.moveTo(relX(30),relY(90));
// 	path.lineTo(relX(30),relY(230));
// 
// 	path.moveTo(relX(127),relY(90));
// 	path.lineTo(relX(127),relY(230));
// 
//     path.moveTo(relX(145),relY(90));
//     path.lineTo(relX(145),relY(230));
// 
//     path.moveTo(relX(160),relY(90));
// 	path.lineTo(relX(160),relY(230));
// 
// 	path.moveTo(relX(180),relY(90));
// 	path.lineTo(relX(180),relY(230));
// 
// 	f.setPointSize(8);
// 	painter.setFont(f);
// 	painter.drawText(relX(22), relY(94), trUtf8("Рб."));
// 	painter.drawText(relX(32), relY(94), trUtf8("Опис на артикли"));
// 
// 	painter.drawText(relX(130), relY(94), trUtf8("Кол."));
// 	painter.drawText(relX(148), relY(94), trUtf8("Ед.мера"));
// 	painter.drawText(relX(165), relY(94), trUtf8("Цена"));
// 	painter.drawText(relX(182), relY(94), trUtf8("Износ"));
// 	path.moveTo(relX(20),relY(275));
// 	path.lineTo(relX(70),relY(275));
// 	path.moveTo(relX(140),relY(275));
// 	path.lineTo(relX(190),relY(275));
// 	painter.drawText(relX(25), relY(280), trUtf8("Предал"));
// 	painter.drawText(relX(145), relY(280), trUtf8("Примил"));
// 
// 
// 	painter.drawPath(path);
//     QStandardItemModel * modelIspratnica2 = m_myispratnici->getModel2();
//     if (modelIspratnica2)
//     {
//         int maxRowPage = 21;
//         maxpage = modelIspratnica2->rowCount() / (maxRowPage + 1) + 1;
//         int pagefrom = page * maxRowPage;
//         int pageto = (page + 1) * maxRowPage < modelIspratnica2->rowCount() ? (page + 1) * maxRowPage : modelIspratnica2->rowCount();
// 
//         for (int row = pagefrom; row < pageto; row++)
//         {
//             for (int col = 0; col < modelIspratnica2->columnCount(); col++)
//             {
//                 switch (col)
//                 {
//                 case 0: painter.drawText(relX(21), relY(100 + 6 * (row - pagefrom)), relX(8), relY(9), Qt::AlignLeft, QString::number(row + 1, 10));break;
//                 case 1: painter.drawText(relX(31), relY(100 + 6 * (row - pagefrom)), relX(96), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 2)->text());break;
//                 case 2: painter.drawText(relX(128), relY(100 + 6 * (row - pagefrom)), relX(16), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 4)->text());break;
//                 case 3: painter.drawText(relX(146), relY(100 + 6 * (row - pagefrom)), relX(16), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 3)->text());break;
//                 case 4: painter.drawText(relX(163), relY(100 + 6 * (row - pagefrom)), relX(16), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 5)->text());break;
//                 case 5: 
//                     float iznos = loc.toFloat(modelIspratnica2->item(row, 4)->text()) * loc.toFloat(modelIspratnica2->item(row, 5)->text()); 
//                     painter.drawText(relX(184), relY(100 + 6 * (row - pagefrom)), relX(15), relY(9), Qt::AlignRight, loc.toString(iznos, 'f', 2));break;
//                 }
//             }
//         }
//     }
//     if( page < maxpage-1 )
//         printer->newPage();
//     }
// }


void sterna::drawPLTM(QPrinter *printer, QPainter& painter)
{
	QLocale loc;
	int maxpage = 1;
	float sumaNabIznos = 0.0f;
	float sumaNabIznosDDV = 0.0f;
	float sumaProdIznos = 0.0f;
	float sumaProdIznosDDV = 0.0f;


	QFont f;
	for( int page=0; page<maxpage; page++)
	{

		QFont f;
		QPainterPath path;
		painter.drawLine(relX(10), relY(19), relX(200), relY(19));
		painter.drawLine(relX(10), relY(27), relX(200), relY(27));
		QStringList modelIspratnicaInfo = m_pltm->getIspratnicaInfo();

		f.setPointSize(16);
		painter.setFont(f);
		painter.drawText(relX(15), relY(20), relX(160), relY(22), Qt::AlignLeft, trUtf8("Приемен лист во трговија на мало број: ") + modelIspratnicaInfo.at(10));
		f.setPointSize(8);



		painter.setFont(f);

		painter.drawText(relX(15), relY(40), relX(40), relY(42), Qt::AlignLeft, modelIspratnicaInfo.at(5));
		painter.drawText(relX(15), relY(45), relX(40), relY(47), Qt::AlignLeft, modelIspratnicaInfo.at(6));
		painter.drawText(relX(15), relY(50), relX(40), relY(52), Qt::AlignLeft, modelIspratnicaInfo.at(7));
		painter.drawText(relX(15), relY(55), relX(40), relY(57), Qt::AlignLeft, modelIspratnicaInfo.at(8));
		painter.drawText(relX(15), relY(60), relX(40), relY(62), Qt::AlignLeft, modelIspratnicaInfo.at(9));


		painter.drawText(relX(100), relY(40), relX(40), relY(42), Qt::AlignRight, trUtf8("Назив на добавувач:"));
		painter.drawText(relX(100), relY(45), relX(40), relY(47), Qt::AlignRight, trUtf8("Седиште на добавувач:"));
		painter.drawText(relX(100), relY(50), relX(40), relY(52), Qt::AlignRight, trUtf8("Град на добавувач:"));
		painter.drawText(relX(100), relY(55), relX(40), relY(57), Qt::AlignRight, trUtf8("Дата на документ:"));
		painter.drawText(relX(100), relY(60), relX(40), relY(62), Qt::AlignRight, trUtf8("Број на документ:"));
		
		painter.drawText(relX(145), relY(40), relX(40), relY(42), Qt::AlignLeft, modelIspratnicaInfo.at(0));
		painter.drawText(relX(145), relY(45), relX(40), relY(47), Qt::AlignLeft, modelIspratnicaInfo.at(1));
		painter.drawText(relX(145), relY(50), relX(40), relY(52), Qt::AlignLeft, modelIspratnicaInfo.at(2));
		painter.drawText(relX(145), relY(55), relX(40), relY(57), Qt::AlignLeft, modelIspratnicaInfo.at(3));
		painter.drawText(relX(145), relY(60), relX(40), relY(62), Qt::AlignLeft, modelIspratnicaInfo.at(4));


		painter.drawRoundedRect(relX(10), relY(90), relX(190), relY(145), relX(2), relY(2), Qt::AbsoluteSize );
		path.moveTo(relX(10),relY(101));
		path.lineTo(relX(200),relY(101));

		path.moveTo(relX(16),relY(90));
		path.lineTo(relX(16),relY(235));

		path.moveTo(relX(61),relY(90));
		path.lineTo(relX(61),relY(235));

		path.moveTo(relX(71),relY(90));
		path.lineTo(relX(71),relY(235));

		path.moveTo(relX(84),relY(90));
		path.lineTo(relX(84),relY(235));

		path.moveTo(relX(100),relY(90));
		path.lineTo(relX(100),relY(235));

		path.moveTo(relX(116),relY(90));
		path.lineTo(relX(116),relY(235));

		path.moveTo(relX(132),relY(90));
		path.lineTo(relX(132),relY(235));

		path.moveTo(relX(148),relY(90));
		path.lineTo(relX(148),relY(235));

		path.moveTo(relX(164),relY(90));
		path.lineTo(relX(164),relY(235));

		path.moveTo(relX(182),relY(90));
		path.lineTo(relX(182),relY(235));

		painter.drawText(relX(11), relY(94), trUtf8("Рб."));
		painter.drawText(relX(11), relY(100), trUtf8("(1)"));

		painter.drawText(relX(17), relY(94), trUtf8("Назив на"));
		painter.drawText(relX(17), relY(97), trUtf8("стоката"));
		painter.drawText(relX(17), relY(100), trUtf8("(2)"));

		painter.drawText(relX(62), relY(94), trUtf8("Един."));
		painter.drawText(relX(62), relY(97), trUtf8("мера"));
		painter.drawText(relX(62), relY(100), trUtf8("(3)"));

		painter.drawText(relX(72), relY(94), trUtf8("Кол."));
		painter.drawText(relX(72), relY(100), trUtf8("(4)"));

		painter.drawText(relX(85), relY(94), trUtf8("Един."));
		painter.drawText(relX(85), relY(97), trUtf8("цена"));
		painter.drawText(relX(85), relY(100), trUtf8("(5)"));

		painter.drawText(relX(101), relY(94), trUtf8("Износ"));
		painter.drawText(relX(101), relY(100), trUtf8("(6)"));

		painter.drawText(relX(117), relY(94), trUtf8("ДДВ при"));
		painter.drawText(relX(117), relY(97), trUtf8("Набавка."));
		painter.drawText(relX(117), relY(100), trUtf8("(7)"));

		painter.drawText(relX(133), relY(94), trUtf8("Ставка"));
		painter.drawText(relX(133), relY(97), trUtf8("ДДВ"));
		painter.drawText(relX(133), relY(100), trUtf8("(8)"));

		painter.drawText(relX(149), relY(94), trUtf8("Ед.Цена"));
		painter.drawText(relX(149), relY(97), trUtf8("Продажна."));
		painter.drawText(relX(149), relY(100), trUtf8("(9)"));

		painter.drawText(relX(165), relY(94), trUtf8("Износ"));
		painter.drawText(relX(165), relY(100), trUtf8("(10)"));

		painter.drawText(relX(183), relY(94), trUtf8("Вк.ДДВ"));
		painter.drawText(relX(183), relY(97), trUtf8("во прод."));
		painter.drawText(relX(183), relY(100), trUtf8("(11)"));

		path.moveTo(relX(140),relY(255));
		path.lineTo(relX(190),relY(255));
		painter.drawText(relX(100), relY(258), trUtf8("(М.П.)"));
		painter.drawText(relX(145), relY(258), trUtf8("Потпис на овластено лице"));
		path.moveTo(relX(10),relY(243));
		path.lineTo(relX(200),relY(243));

		painter.drawPath(path);

		QStandardItemModel * modelFaktura2 = m_pltm->getModel2();

		if (modelFaktura2)
		{
			int maxRowPage = 21;
			maxpage = modelFaktura2->rowCount() / (maxRowPage + 1) + 1;
			int pagefrom = page * maxRowPage;
			int pageto = (page + 1) * maxRowPage < modelFaktura2->rowCount() ? (page + 1) * maxRowPage : modelFaktura2->rowCount();

			for (int row = pagefrom; row < pageto; row++)
			{
				for (int col = 0; col < 11; col++)
				{
					switch (col)
					{
					case 0: painter.drawText(relX(11),  relY(102 + 6 * (row - pagefrom)), relX(6), relY(5), Qt::AlignLeft, QString::number(row + 1, 10));break;
					case 1: painter.drawText(relX(17),  relY(102 + 6 * (row - pagefrom)), relX(44), relY(5), Qt::AlignLeft, modelFaktura2->item(row, col)->text());
						painter.drawText(relX(17),  relY(105 + 6 * (row - pagefrom)), relX(44), relY(5), Qt::AlignLeft, trUtf8("Шифра бр:") + modelFaktura2->item(row, 0)->text());
						break;
					case 2: painter.drawText(relX(62),  relY(102 + 6 * (row - pagefrom)), relX(9), relY(5), Qt::AlignLeft, modelFaktura2->item(row, col)->text());break;
					case 3: painter.drawText(relX(72),  relY(102 + 6 * (row - pagefrom)), relX(12), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());break;
					case 4: painter.drawText(relX(85),  relY(102 + 6 * (row - pagefrom)), relX(15), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());break;
					case 5: painter.drawText(relX(101), relY(102 + 6 * (row - pagefrom)), relX(15), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());
						sumaNabIznos =sumaNabIznos + loc.toFloat(modelFaktura2->item(row, 5)->text());
						break;
					case 6: painter.drawText(relX(117), relY(102 + 6 * (row - pagefrom)), relX(15), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());
						sumaNabIznosDDV =sumaNabIznosDDV + loc.toFloat(modelFaktura2->item(row, 6)->text());
						break;
					case 7: painter.drawText(relX(133), relY(102 + 6 * (row - pagefrom)), relX(15), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());break;
					case 8: painter.drawText(relX(149), relY(102 + 6 * (row - pagefrom)), relX(15), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());break;
					case 9: painter.drawText(relX(165), relY(102 + 6 * (row - pagefrom)), relX(17), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());
						sumaProdIznos =sumaProdIznos + loc.toFloat(modelFaktura2->item(row, 9)->text());
						break;
					case 10: painter.drawText(relX(183), relY(102 + 6 * (row - pagefrom)), relX(17), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());
						sumaProdIznosDDV =sumaProdIznosDDV + loc.toFloat(modelFaktura2->item(row, 10)->text());	
						break;
					}
				}
			}
		}
		if( page < maxpage-1 )
			printer->newPage();
	}

	painter.drawText(relX(15), relY(238), relX(30), relY(5), Qt::AlignRight,  trUtf8("Вкупен износ:"));
	painter.drawText(relX(101), relY(238), relX(15), relY(5), Qt::AlignRight,  loc.toString(sumaNabIznos, 'f', 2));
	painter.drawText(relX(117), relY(238), relX(15), relY(5), Qt::AlignRight,  loc.toString(sumaNabIznosDDV, 'f', 2));
	painter.drawText(relX(165), relY(238), relX(15), relY(5), Qt::AlignRight,  loc.toString(sumaProdIznos, 'f', 2));
	painter.drawText(relX(183), relY(238), relX(15), relY(5), Qt::AlignRight,  loc.toString(sumaProdIznosDDV, 'f', 2));
}

void sterna::drawProdPovratnica(QPrinter *printer, QPainter& painter)
{
	QLocale loc;
	int maxpage = 1;
	float sumaNabIznos = 0.0f;
	float sumaNabIznosDDV = 0.0f;
	float sumaProdIznos = 0.0f;
	float sumaProdIznosDDV = 0.0f;


	QFont f;
	for( int page=0; page<maxpage; page++)
	{

		QFont f;
		QPainterPath path;
		painter.drawLine(relX(10), relY(19), relX(200), relY(19));
		painter.drawLine(relX(10), relY(27), relX(200), relY(27));
		QStringList modelIspratnicaInfo = m_prodsmetka->getIspratnicaInfo();

		f.setPointSize(16);
		painter.setFont(f);
		painter.drawText(relX(15), relY(20), relX(160), relY(22), Qt::AlignLeft, trUtf8("Повратница во трговија на мало број: ") + modelIspratnicaInfo.at(10));
		f.setPointSize(8);



		painter.setFont(f);

		painter.drawText(relX(15), relY(40), relX(40), relY(42), Qt::AlignLeft, modelIspratnicaInfo.at(5));
		painter.drawText(relX(15), relY(45), relX(40), relY(47), Qt::AlignLeft, modelIspratnicaInfo.at(6));
		painter.drawText(relX(15), relY(50), relX(40), relY(52), Qt::AlignLeft, modelIspratnicaInfo.at(7));
		painter.drawText(relX(15), relY(55), relX(40), relY(57), Qt::AlignLeft, modelIspratnicaInfo.at(8));
		painter.drawText(relX(15), relY(60), relX(40), relY(62), Qt::AlignLeft, modelIspratnicaInfo.at(9));


		painter.drawText(relX(100), relY(40), relX(40), relY(42), Qt::AlignRight, trUtf8("Назив на добавувач:"));
		painter.drawText(relX(100), relY(45), relX(40), relY(47), Qt::AlignRight, trUtf8("Седиште на добавувач:"));
		painter.drawText(relX(100), relY(50), relX(40), relY(52), Qt::AlignRight, trUtf8("Град на добавувач:"));
		painter.drawText(relX(100), relY(55), relX(40), relY(57), Qt::AlignRight, trUtf8("Дата на документ:"));
		painter.drawText(relX(100), relY(60), relX(40), relY(62), Qt::AlignRight, trUtf8("Број на документ:"));

		painter.drawText(relX(145), relY(40), relX(40), relY(42), Qt::AlignLeft, modelIspratnicaInfo.at(0));
		painter.drawText(relX(145), relY(45), relX(40), relY(47), Qt::AlignLeft, modelIspratnicaInfo.at(1));
		painter.drawText(relX(145), relY(50), relX(40), relY(52), Qt::AlignLeft, modelIspratnicaInfo.at(2));
		painter.drawText(relX(145), relY(55), relX(40), relY(57), Qt::AlignLeft, modelIspratnicaInfo.at(3));
		painter.drawText(relX(145), relY(60), relX(40), relY(62), Qt::AlignLeft, modelIspratnicaInfo.at(4));


		painter.drawRoundedRect(relX(10), relY(90), relX(190), relY(145), relX(2), relY(2), Qt::AbsoluteSize );
		path.moveTo(relX(10),relY(101));
		path.lineTo(relX(200),relY(101));

		path.moveTo(relX(16),relY(90));
		path.lineTo(relX(16),relY(235));

		path.moveTo(relX(61),relY(90));
		path.lineTo(relX(61),relY(235));

		path.moveTo(relX(71),relY(90));
		path.lineTo(relX(71),relY(235));

		path.moveTo(relX(84),relY(90));
		path.lineTo(relX(84),relY(235));

		path.moveTo(relX(100),relY(90));
		path.lineTo(relX(100),relY(235));

		path.moveTo(relX(116),relY(90));
		path.lineTo(relX(116),relY(235));

		path.moveTo(relX(132),relY(90));
		path.lineTo(relX(132),relY(235));

		path.moveTo(relX(148),relY(90));
		path.lineTo(relX(148),relY(235));

		path.moveTo(relX(164),relY(90));
		path.lineTo(relX(164),relY(235));

		path.moveTo(relX(182),relY(90));
		path.lineTo(relX(182),relY(235));

		painter.drawText(relX(11), relY(94), trUtf8("Рб."));
		painter.drawText(relX(11), relY(100), trUtf8("(1)"));

		painter.drawText(relX(17), relY(94), trUtf8("Назив на"));
		painter.drawText(relX(17), relY(97), trUtf8("стоката"));
		painter.drawText(relX(17), relY(100), trUtf8("(2)"));

		painter.drawText(relX(62), relY(94), trUtf8("Един."));
		painter.drawText(relX(62), relY(97), trUtf8("мера"));
		painter.drawText(relX(62), relY(100), trUtf8("(3)"));

		painter.drawText(relX(72), relY(94), trUtf8("Кол."));
		painter.drawText(relX(72), relY(100), trUtf8("(4)"));

		painter.drawText(relX(85), relY(94), trUtf8("Един."));
		painter.drawText(relX(85), relY(97), trUtf8("цена"));
		painter.drawText(relX(85), relY(100), trUtf8("(5)"));

		painter.drawText(relX(101), relY(94), trUtf8("Износ"));
		painter.drawText(relX(101), relY(100), trUtf8("(6)"));

		painter.drawText(relX(117), relY(94), trUtf8("ДДВ при"));
		painter.drawText(relX(117), relY(97), trUtf8("Набавка."));
		painter.drawText(relX(117), relY(100), trUtf8("(7)"));

		painter.drawText(relX(133), relY(94), trUtf8("Ставка"));
		painter.drawText(relX(133), relY(97), trUtf8("ДДВ"));
		painter.drawText(relX(133), relY(100), trUtf8("(8)"));

		painter.drawText(relX(149), relY(94), trUtf8("Ед.Цена"));
		painter.drawText(relX(149), relY(97), trUtf8("Продажна."));
		painter.drawText(relX(149), relY(100), trUtf8("(9)"));

		painter.drawText(relX(165), relY(94), trUtf8("Износ"));
		painter.drawText(relX(165), relY(100), trUtf8("(10)"));

		painter.drawText(relX(183), relY(94), trUtf8("Вк.ДДВ"));
		painter.drawText(relX(183), relY(97), trUtf8("во прод."));
		painter.drawText(relX(183), relY(100), trUtf8("(11)"));

		path.moveTo(relX(140),relY(255));
		path.lineTo(relX(190),relY(255));
		painter.drawText(relX(100), relY(258), trUtf8("(М.П.)"));
		painter.drawText(relX(145), relY(258), trUtf8("Потпис на овластено лице"));
		path.moveTo(relX(10),relY(243));
		path.lineTo(relX(200),relY(243));

		painter.drawPath(path);

		QStandardItemModel * modelFaktura2 = m_prodsmetka->getModel2();

		if (modelFaktura2)
		{
			int maxRowPage = 21;
			maxpage = modelFaktura2->rowCount() / (maxRowPage + 1) + 1;
			int pagefrom = page * maxRowPage;
			int pageto = (page + 1) * maxRowPage < modelFaktura2->rowCount() ? (page + 1) * maxRowPage : modelFaktura2->rowCount();

			for (int row = pagefrom; row < pageto; row++)
			{
				for (int col = 0; col < 11; col++)
				{
					switch (col)
					{
					case 0: painter.drawText(relX(11),  relY(102 + 6 * (row - pagefrom)), relX(6), relY(5), Qt::AlignLeft, QString::number(row + 1, 10));break;
					case 1: painter.drawText(relX(17),  relY(102 + 6 * (row - pagefrom)), relX(44), relY(5), Qt::AlignLeft, modelFaktura2->item(row, col)->text());
						painter.drawText(relX(17),  relY(105 + 6 * (row - pagefrom)), relX(44), relY(5), Qt::AlignLeft, trUtf8("Шифра бр:") + modelFaktura2->item(row, 0)->text());
						break;
					case 2: painter.drawText(relX(62),  relY(102 + 6 * (row - pagefrom)), relX(9), relY(5), Qt::AlignLeft, modelFaktura2->item(row, col)->text());break;
					case 3: painter.drawText(relX(72),  relY(102 + 6 * (row - pagefrom)), relX(12), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());break;
					case 4: painter.drawText(relX(85),  relY(102 + 6 * (row - pagefrom)), relX(15), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());break;
					case 5: painter.drawText(relX(101), relY(102 + 6 * (row - pagefrom)), relX(15), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());
						sumaNabIznos =sumaNabIznos + loc.toFloat(modelFaktura2->item(row, 5)->text());
						break;
					case 6: painter.drawText(relX(117), relY(102 + 6 * (row - pagefrom)), relX(15), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());
						sumaNabIznosDDV =sumaNabIznosDDV + loc.toFloat(modelFaktura2->item(row, 6)->text());
						break;
					case 7: painter.drawText(relX(133), relY(102 + 6 * (row - pagefrom)), relX(15), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());break;
					case 8: painter.drawText(relX(149), relY(102 + 6 * (row - pagefrom)), relX(15), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());break;
					case 9: painter.drawText(relX(165), relY(102 + 6 * (row - pagefrom)), relX(17), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());
						sumaProdIznos =sumaProdIznos + loc.toFloat(modelFaktura2->item(row, 9)->text());
						break;
					case 10: painter.drawText(relX(183), relY(102 + 6 * (row - pagefrom)), relX(17), relY(5), Qt::AlignRight,  modelFaktura2->item(row, col)->text());
						sumaProdIznosDDV =sumaProdIznosDDV + loc.toFloat(modelFaktura2->item(row, 10)->text());	
						break;
					}
				}
			}
		}
		if( page < maxpage-1 )
			printer->newPage();
	}

	painter.drawText(relX(15), relY(238), relX(30), relY(5), Qt::AlignRight,  trUtf8("Вкупен износ:"));
	painter.drawText(relX(101), relY(238), relX(15), relY(5), Qt::AlignRight,  loc.toString(sumaNabIznos, 'f', 2));
	painter.drawText(relX(117), relY(238), relX(15), relY(5), Qt::AlignRight,  loc.toString(sumaNabIznosDDV, 'f', 2));
	painter.drawText(relX(165), relY(238), relX(15), relY(5), Qt::AlignRight,  loc.toString(sumaProdIznos, 'f', 2));
	painter.drawText(relX(183), relY(238), relX(15), relY(5), Qt::AlignRight,  loc.toString(sumaProdIznosDDV, 'f', 2));
}

void sterna::drawProdSmetka(QPrinter *printer, QPainter& painter)
{
	QLocale loc;
	int maxpage = 1;
	float suma = 0.0f;
	float ddv = 0.0f;
	float sumaDDV = 0.0f;


	QFont f;
	for( int page=0; page<maxpage; page++)
	{

		QFont f;
		QPainterPath path;

		f.setPointSize(18);
		painter.setFont(f);
		painter.drawText(relX(160), relY(60), relX(40), relY(60), Qt::AlignRight, trUtf8("Сметка"));
		f.setPointSize(8);

		QStringList modelIspratnicaInfo = m_prodsmetka->getIspratnicaInfo();

		painter.setFont(f);
		painter.drawText(relX(100), relY(75), relX(100), relY(65), Qt::AlignRight, trUtf8("Сериски Број: ") + modelIspratnicaInfo.at(10));
		painter.drawText(relX(100), relY(78), relX(100), relY(70), Qt::AlignRight, trUtf8("Датум: ") + modelIspratnicaInfo.at(3));
		painter.drawText(relX(100), relY(81), relX(100), relY(75), Qt::AlignRight, trUtf8("Валута: ") + modelIspratnicaInfo.at(3));
		painter.drawText(relX(100), relY(84), relX(100), relY(80), Qt::AlignRight, trUtf8("Продавница: ") + modelIspratnicaInfo.at(5));

		//         painter.drawRoundedRect(relX(20), relY(55), relX(80), relY(30), relX(3), relY(3), Qt::AbsoluteSize );
		painter.drawText(relX(25), relY(70), trUtf8("До:"));


		painter.drawText(relX(25), relY(75), modelIspratnicaInfo.at(0));
		painter.drawText(relX(25), relY(80), modelIspratnicaInfo.at(1));
		painter.drawText(relX(25), relY(85), modelIspratnicaInfo.at(2));

		painter.drawRoundedRect(relX(10), relY(90), relX(190), relY(145), relX(2), relY(2), Qt::AbsoluteSize );
		path.moveTo(relX(10),relY(95));
		path.lineTo(relX(200),relY(95));

		path.moveTo(relX(15),relY(90));
		path.lineTo(relX(15),relY(235));

		path.moveTo(relX(70),relY(90));
		path.lineTo(relX(70),relY(235));

		path.moveTo(relX(80),relY(90));
		path.lineTo(relX(80),relY(235));

		path.moveTo(relX(92),relY(90));
		path.lineTo(relX(92),relY(235));

		path.moveTo(relX(110),relY(90));
		path.lineTo(relX(110),relY(235));

		path.moveTo(relX(120),relY(90));
		path.lineTo(relX(120),relY(235));

		path.moveTo(relX(140),relY(90));
		path.lineTo(relX(140),relY(235));

		path.moveTo(relX(150),relY(90));
		path.lineTo(relX(150),relY(235));

		path.moveTo(relX(175),relY(90));
		path.lineTo(relX(175),relY(235));

		painter.drawText(relX(11), relY(94), trUtf8("Рб."));
		painter.drawText(relX(17), relY(94), trUtf8("Опис на артикал - услуга"));
		painter.drawText(relX(72), relY(94), trUtf8("Кол."));
		painter.drawText(relX(82), relY(94), trUtf8("Едм."));
		painter.drawText(relX(95), relY(94), trUtf8("Цена"));
		painter.drawText(relX(111), relY(94), trUtf8("Раб.%"));
		painter.drawText(relX(122), relY(94), trUtf8("Цена/рабат"));
		painter.drawText(relX(141), relY(94), trUtf8("ДДВ%"));
		painter.drawText(relX(152), relY(94), trUtf8("ДДВ Износ"));
		painter.drawText(relX(177), relY(94), trUtf8("Вкупно"));

		path.moveTo(relX(10),relY(255));
		path.lineTo(relX(70),relY(255));
		path.moveTo(relX(140),relY(255));
		path.lineTo(relX(190),relY(255));
		painter.drawText(relX(11), relY(258), trUtf8("Изготвил"));
		painter.drawText(relX(145), relY(258), trUtf8("Примил"));
		path.moveTo(relX(10),relY(243));
		path.lineTo(relX(200),relY(243));

		painter.drawPath(path);

		QStandardItemModel * modelFaktura2 = m_prodsmetka->getModel2();

		if (modelFaktura2)
		{
			int maxRowPage = 21;
			maxpage = modelFaktura2->rowCount() / (maxRowPage + 1) + 1;
			int pagefrom = page * maxRowPage;
			int pageto = (page + 1) * maxRowPage < modelFaktura2->rowCount() ? (page + 1) * maxRowPage : modelFaktura2->rowCount();
			float cena1 = 0;
			float rabat1 = 0;
			float cenarabat1 = 0;
			for (int row = pagefrom; row < pageto; row++)
			{
				for (int col = 0; col < 10; col++)
				{
					switch (col)
					{
					case 0: painter.drawText(relX(11), relY(100 + 6 * (row - pagefrom)), relX(4), relY(9), Qt::AlignLeft, QString::number(row + 1, 10));break;
					case 1: 
						painter.drawText(relX(16), relY(100 + 6 * (row - pagefrom)), relX(54), relY(9), Qt::AlignLeft, modelFaktura2->item(row, 1)->text());
						// 					f.setPointSize(8);
						// 					painter.setFont(f);
						break;
					case 2: painter.drawText(relX(71), relY(100 + 6 * (row - pagefrom)), relX(9), relY(9), Qt::AlignRight, modelFaktura2->item(row, 3)->text());break;
					case 3: painter.drawText(relX(81), relY(100 + 6 * (row - pagefrom)), relX(14), relY(9), Qt::AlignLeft,  modelFaktura2->item(row, 2)->text());break;
					case 4: painter.drawText(relX(96), relY(100 + 6 * (row - pagefrom)), relX(14), relY(9), Qt::AlignRight,  modelFaktura2->item(row, 5)->text());break;
					case 5: painter.drawText(relX(111), relY(100 + 6 * (row - pagefrom)), relX(9), relY(9), Qt::AlignRight,  modelFaktura2->item(row, 6)->text());break;
					case 6: 
 						cena1 = loc.toFloat(modelFaktura2->item(row, 5)->text());
						rabat1 = loc.toFloat(modelFaktura2->item(row, 6)->text());
						cenarabat1 = cena1 /(1-rabat1/100);
						painter.drawText(relX(121), relY(100 + 6 * (row - pagefrom)), relX(19), relY(9), Qt::AlignRight, loc.toString(cenarabat1, 'f', 2));
						break;
 					case 7: painter.drawText(relX(141), relY(100 + 6 * (row - pagefrom)), relX(9), relY(9), Qt::AlignRight,  modelFaktura2->item(row, 4)->text());break;
 					case 8: painter.drawText(relX(152), relY(100 + 6 * (row - pagefrom)), relX(23), relY(15), Qt::AlignRight,  modelFaktura2->item(row, col)->text());
						ddv =ddv + loc.toFloat(modelFaktura2->item(row, col)->text());
						break;
 					case 9: painter.drawText(relX(177), relY(100 + 6 * (row - pagefrom)), relX(23), relY(15), Qt::AlignRight,  modelFaktura2->item(row, 7)->text());
						sumaDDV =sumaDDV + loc.toFloat(modelFaktura2->item(row, 7)->text());
						break;
					}
				}
			}
		}
		if( page < maxpage-1 )
			printer->newPage();
	}

	painter.drawText(relX(130), relY(235), relX(40), relY(10), Qt::AlignRight, trUtf8("Вкупен ДДВ"));
	painter.drawText(relX(170), relY(235), relX(30), relY(10), Qt::AlignRight, loc.toString( ddv, 'f', 2) + trUtf8("  ден."));

	painter.drawText(relX(130), relY(239), relX(40), relY(10), Qt::AlignRight, trUtf8("Вкупно за наплата денари"));
	painter.drawText(relX(170), relY(239), relX(30), relY(10), Qt::AlignRight, loc.toString( sumaDDV, 'f', 2) + trUtf8("  ден."));

	// 	painter.drawText(relX(15), relY(280), trUtf8("Фактурирал"));

	f.setPointSize(7);
	painter.setFont(f);
	int p = int(sumaDDV + 0.5f);
	QString t = convertIntToText(p);
	painter.drawText(relX(10), relY(243), relX(120), relY(6), Qt::AlignLeft,t);
}

void sterna::drawIspratnica(QPrinter *printer, QPainter& painter)
{
    QLocale loc;
    int maxpage = 1;
    for( int page=0; page<maxpage; page++)
    {
		QFont f;
		QPainterPath path;

		f.setPointSize(18);
		painter.setFont(f);
		painter.drawText(relX(160), relY(66), relX(40), relY(60), Qt::AlignRight, trUtf8("Испратница"));
		f.setPointSize(8);

		QStringList modelIspratnicaInfo = m_myispratnici->getIspratnicaInfo();

		painter.setFont(f);
		f.setPointSize(10);
		painter.setFont(f);
		painter.drawText(relX(160), relY(76), relX(40), relY(65), Qt::AlignRight, trUtf8("Сериски Број: ") + modelIspratnicaInfo.at(4));
		f.setPointSize(8);
		painter.setFont(f);
		painter.drawText(relX(160), relY(81), relX(40), relY(70), Qt::AlignRight, trUtf8("Датум: ") + modelIspratnicaInfo.at(3));
		painter.drawText(relX(160), relY(84), relX(40), relY(75), Qt::AlignRight, trUtf8("Валута: ") + modelIspratnicaInfo.at(3));
		//         painter.drawRoundedRect(relX(20), relY(55), relX(80), relY(30), relX(3), relY(3), Qt::AbsoluteSize );
		painter.drawText(relX(25), relY(70), trUtf8("До:"));

		f.setPointSize(10);
		painter.setFont(f);
		painter.drawText(relX(25), relY(75), modelIspratnicaInfo.at(0));
		f.setPointSize(8);
		painter.setFont(f);

		painter.drawText(relX(25), relY(80), modelIspratnicaInfo.at(1));
		painter.drawText(relX(25), relY(85), modelIspratnicaInfo.at(2));

        painter.drawRoundedRect(relX(20), relY(90), relX(180), relY(140), relX(2), relY(2), Qt::AbsoluteSize );
        path.moveTo(relX(20),relY(95));
        path.lineTo(relX(200),relY(95));

        path.moveTo(relX(30),relY(90));
        path.lineTo(relX(30),relY(230));

        path.moveTo(relX(127),relY(90));
        path.lineTo(relX(127),relY(230));

        path.moveTo(relX(145),relY(90));
        path.lineTo(relX(145),relY(230));

        path.moveTo(relX(160),relY(90));
        path.lineTo(relX(160),relY(230));

        path.moveTo(relX(180),relY(90));
        path.lineTo(relX(180),relY(230));

        f.setPointSize(8);
        painter.setFont(f);
        painter.drawText(relX(22), relY(94), trUtf8("Рб."));
        painter.drawText(relX(32), relY(94), trUtf8("Опис на артикли"));

        painter.drawText(relX(130), relY(94), trUtf8("Кол."));
        painter.drawText(relX(148), relY(94), trUtf8("Ед.мера"));
        painter.drawText(relX(165), relY(94), trUtf8("Цена"));
        painter.drawText(relX(182), relY(94), trUtf8("Износ"));
        

        path.moveTo(relX(170),relY(242));
        path.lineTo(relX(200),relY(242));

        painter.drawText(relX(20), relY(245), trUtf8("* Купувачот ја прегледал и ја прима стоката во исправна состојба!"));
        painter.drawText(relX(20), relY(248), trUtf8("Рекламации после приемот не се примаат!"));

        painter.drawText(relX(170), relY(245), trUtf8("   Датум на прием"));

        path.moveTo(relX(20),relY(257));
        path.lineTo(relX(50),relY(257));
        path.moveTo(relX(90),relY(257));
        path.lineTo(relX(120),relY(257));
        path.moveTo(relX(170),relY(257));
        path.lineTo(relX(200),relY(257));


        painter.drawText(relX(20), relY(260), trUtf8("Издал"));
        painter.drawText(relX(90), relY(260), trUtf8("Возач"));
        painter.drawText(relX(170), relY(260), trUtf8("   Примил"));
        painter.drawText(relX(170), relY(263), trUtf8("Име и Презиме"));


        painter.drawPath(path);
        QStandardItemModel * modelIspratnica2 = m_myispratnici->getModel2();
        if (modelIspratnica2)
        {
            int maxRowPage = 21;
            maxpage = modelIspratnica2->rowCount() / (maxRowPage + 1) + 1;
            int pagefrom = page * maxRowPage;
            int pageto = (page + 1) * maxRowPage < modelIspratnica2->rowCount() ? (page + 1) * maxRowPage : modelIspratnica2->rowCount();

            for (int row = pagefrom; row < pageto; row++)
            {
                for (int col = 0; col < modelIspratnica2->columnCount(); col++)
                {
                    switch (col)
                    {
                    case 0: painter.drawText(relX(21), relY(100 + 6 * (row - pagefrom)), relX(8), relY(9), Qt::AlignLeft, QString::number(row + 1, 10));break;
                    case 1: painter.drawText(relX(31), relY(100 + 6 * (row - pagefrom)), relX(96), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 1)->text() +" - "+modelIspratnica2->item(row, 2)->text());break;
                    case 2: painter.drawText(relX(128), relY(100 + 6 * (row - pagefrom)), relX(16), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 4)->text());break;
                    case 3: painter.drawText(relX(146), relY(100 + 6 * (row - pagefrom)), relX(16), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 3)->text());break;
                    case 4: painter.drawText(relX(163), relY(100 + 6 * (row - pagefrom)), relX(16), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 5)->text());break;
                    case 5: 
                        float iznos = loc.toFloat(modelIspratnica2->item(row, 4)->text()) * loc.toFloat(modelIspratnica2->item(row, 5)->text()); 
                        painter.drawText(relX(184), relY(100 + 6 * (row - pagefrom)), relX(15), relY(9), Qt::AlignRight, loc.toString(iznos, 'f', 2));break;
                    }
                }
            }
        }
        if( page < maxpage-1 )
            printer->newPage();
    }
}
void sterna::drawIspratnicaMala(QPrinter *printer, QPainter& painter)
{
	QLocale loc;
	int maxpage = 1;
	for( int page=0; page<maxpage; page++)
	{
		QFont f;
		QPainterPath path;

		f.setPointSize(18);
		painter.setFont(f);
		painter.drawText(relX(160), relY(66), relX(40), relY(60), Qt::AlignRight, trUtf8("Испратница"));
		f.setPointSize(8);

		QStringList modelIspratnicaInfo = m_myispratnici->getIspratnicaInfo();

		painter.setFont(f);
		f.setPointSize(10);
		painter.setFont(f);
		painter.drawText(relX(160), relY(76), relX(40), relY(65), Qt::AlignRight, trUtf8("Сериски Број: ") + modelIspratnicaInfo.at(4));
		f.setPointSize(8);
		painter.setFont(f);
		painter.drawText(relX(160), relY(81), relX(40), relY(70), Qt::AlignRight, trUtf8("Датум: ") + modelIspratnicaInfo.at(3));
		painter.drawText(relX(160), relY(84), relX(40), relY(75), Qt::AlignRight, trUtf8("Валута: ") + modelIspratnicaInfo.at(3));
		//         painter.drawRoundedRect(relX(20), relY(55), relX(80), relY(30), relX(3), relY(3), Qt::AbsoluteSize );
		painter.drawText(relX(25), relY(70), trUtf8("До:"));

		f.setPointSize(10);
		painter.setFont(f);
		painter.drawText(relX(25), relY(75), modelIspratnicaInfo.at(0));
		f.setPointSize(8);
		painter.setFont(f);

		painter.drawText(relX(25), relY(80), modelIspratnicaInfo.at(1));
		painter.drawText(relX(25), relY(85), modelIspratnicaInfo.at(2));

		painter.drawRoundedRect(relX(20), relY(90), relX(180), relY(26), relX(2), relY(2), Qt::AbsoluteSize );
		path.moveTo(relX(20),relY(95));
		path.lineTo(relX(200),relY(95));

		path.moveTo(relX(30),relY(90));
		path.lineTo(relX(30),relY(116));

		path.moveTo(relX(127),relY(90));
		path.lineTo(relX(127),relY(116));

		path.moveTo(relX(145),relY(90));
		path.lineTo(relX(145),relY(116));

		path.moveTo(relX(160),relY(90));
		path.lineTo(relX(160),relY(116));

		path.moveTo(relX(180),relY(90));
		path.lineTo(relX(180),relY(116));

		f.setPointSize(8);
		painter.setFont(f);
		painter.drawText(relX(22), relY(94), trUtf8("Рб."));
		painter.drawText(relX(32), relY(94), trUtf8("Опис на артикли"));

		painter.drawText(relX(130), relY(94), trUtf8("Кол."));
		painter.drawText(relX(148), relY(94), trUtf8("Ед.мера"));
		painter.drawText(relX(165), relY(94), trUtf8("Цена"));
		painter.drawText(relX(182), relY(94), trUtf8("Износ"));


		path.moveTo(relX(170),relY(122));
		path.lineTo(relX(200),relY(122));

		painter.drawText(relX(20), relY(125), trUtf8("* Купувачот ја прегледал и ја прима стоката во исправна состојба!"));
		painter.drawText(relX(20), relY(128), trUtf8("Рекламации после приемот не се примаат!"));

		painter.drawText(relX(170), relY(125), trUtf8("   Датум на прием"));

		path.moveTo(relX(20),relY(137));
		path.lineTo(relX(50),relY(137));
		path.moveTo(relX(90),relY(137));
		path.lineTo(relX(120),relY(137));
		path.moveTo(relX(170),relY(137));
		path.lineTo(relX(200),relY(137));


		painter.drawText(relX(20), relY(140), trUtf8("Издал"));
		painter.drawText(relX(90), relY(140), trUtf8("Возач"));
		painter.drawText(relX(170), relY(140), trUtf8("   Примил"));
		painter.drawText(relX(170), relY(143), trUtf8("Име и Презиме"));


		painter.drawPath(path);
		QStandardItemModel * modelIspratnica2 = m_myispratnici->getModel2();
		if (modelIspratnica2)
		{
			int maxRowPage = 4;
			maxpage = modelIspratnica2->rowCount() / (maxRowPage + 1) + 1;
			int pagefrom = page * maxRowPage;
			int pageto = (page + 1) * maxRowPage < modelIspratnica2->rowCount() ? (page + 1) * maxRowPage : modelIspratnica2->rowCount();

			for (int row = pagefrom; row < pageto; row++)
			{
				for (int col = 0; col < modelIspratnica2->columnCount(); col++)
				{
					switch (col)
					{
					case 0: painter.drawText(relX(21), relY(96 + 5 * (row - pagefrom)), relX(8), relY(9), Qt::AlignLeft, QString::number(row + 1, 10));break;
					case 1: painter.drawText(relX(31), relY(96 + 5 * (row - pagefrom)), relX(96), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 1)->text() +" - "+modelIspratnica2->item(row, 2)->text());break;
					case 2: painter.drawText(relX(128), relY(96 + 5 * (row - pagefrom)), relX(16), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 4)->text());break;
					case 3: painter.drawText(relX(146), relY(96 + 5 * (row - pagefrom)), relX(16), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 3)->text());break;
					case 4: painter.drawText(relX(163), relY(96 + 5 * (row - pagefrom)), relX(16), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 5)->text());break;
					case 5: 
						float iznos = loc.toFloat(modelIspratnica2->item(row, 4)->text()) * loc.toFloat(modelIspratnica2->item(row, 5)->text()); 
						painter.drawText(relX(184), relY(96 + 5 * (row - pagefrom)), relX(15), relY(9), Qt::AlignRight, loc.toString(iznos, 'f', 2));break;
					}
				}
			}
		}
		if( page < maxpage-1 )
			printer->newPage();
	}
}

void sterna::drawPriemnica(QPrinter *printer, QPainter& painter)
{
	int maxpage = 1;
	for( int page=0; page<maxpage; page++)
	{
    QFont f;
    QPainterPath path;

    f.setPointSize(18);
    painter.setFont(f);
    painter.drawText(relX(160), relY(68), relX(40), relY(60), Qt::AlignRight, trUtf8("Приемница"));
    f.setPointSize(8);

    QStringList modelIspratnicaInfo = m_mypriemnici->getPriemnicaInfo();
	f.setPointSize(10);
    painter.setFont(f);
    painter.drawText(relX(140), relY(76), relX(60), relY(65), Qt::AlignRight, trUtf8("Сериски Број: ") + modelIspratnicaInfo.at(3));
	f.setPointSize(8);
	painter.setFont(f);

	painter.drawText(relX(160), relY(81), relX(40), relY(70), Qt::AlignRight, trUtf8("Датум: ") + modelIspratnicaInfo.at(4));
    painter.drawText(relX(160), relY(84), relX(40), relY(75), Qt::AlignRight, trUtf8("Валута: ") + modelIspratnicaInfo.at(4));
    //         painter.drawRoundedRect(relX(20), relY(55), relX(80), relY(30), relX(3), relY(3), Qt::AbsoluteSize );
    painter.drawText(relX(25), relY(70), trUtf8("Од:"));

	f.setPointSize(10);
	painter.setFont(f);
    painter.drawText(relX(25), relY(75), modelIspratnicaInfo.at(0));
	f.setPointSize(8);
	painter.setFont(f);

	painter.drawText(relX(25), relY(80), modelIspratnicaInfo.at(1));
    painter.drawText(relX(25), relY(84), modelIspratnicaInfo.at(2));
	painter.drawText(relX(25), relY(88), modelIspratnicaInfo.at(5));

	painter.drawRoundedRect(relX(20), relY(90), relX(180), relY(140), relX(2), relY(2), Qt::AbsoluteSize );

    path.moveTo(relX(20),relY(95));
	path.lineTo(relX(200),relY(95));

	path.moveTo(relX(30),relY(90));
	path.lineTo(relX(30),relY(230));

	path.moveTo(relX(127),relY(90));
	path.lineTo(relX(127),relY(230));


	path.moveTo(relX(145),relY(90));
	path.lineTo(relX(145),relY(230));

	path.moveTo(relX(160),relY(90));
	path.lineTo(relX(160),relY(230));

	path.moveTo(relX(180),relY(90));
	path.lineTo(relX(180),relY(230));

	f.setPointSize(8);
	painter.setFont(f);
	painter.drawText(relX(22), relY(94), trUtf8("Рб."));
	painter.drawText(relX(32), relY(94), trUtf8("Опис на артикли"));

	painter.drawText(relX(130), relY(94), trUtf8("Кол."));
	painter.drawText(relX(148), relY(94), trUtf8("Ед.мера"));
	painter.drawText(relX(165), relY(94), trUtf8("Цена"));
	painter.drawText(relX(182), relY(94), trUtf8("Износ"));
	path.moveTo(relX(20),relY(245));
	path.lineTo(relX(70),relY(245));
	path.moveTo(relX(140),relY(245));
	path.lineTo(relX(190),relY(245));
	painter.drawText(relX(25), relY(248), trUtf8("Предал"));
	painter.drawText(relX(145), relY(248), trUtf8("Примил"));


	painter.drawPath(path);
	QStandardItemModel * modelPriemnica2 = m_mypriemnici->getModel2();
	if (modelPriemnica2)
	{
		int maxRowPage = 21;
        maxpage = modelPriemnica2->rowCount() / (maxRowPage + 1) + 1;
		int pagefrom = page * maxRowPage;
		int pageto = (page + 1) * maxRowPage < modelPriemnica2->rowCount() ? (page + 1) * maxRowPage : modelPriemnica2->rowCount();

		for (int row = pagefrom; row < pageto; row++)
		{
			for (int col = 0; col < modelPriemnica2->columnCount(); col++)
			{
				switch (col)
				{
				case 0: painter.drawText(relX(21), relY(100 + 6 * (row - pagefrom)), relX(8), relY(9), Qt::AlignLeft, QString::number(row + 1, 10));break;
				case 1: painter.drawText(relX(31), relY(100 + 6 * (row - pagefrom)), relX(96), relY(9), Qt::AlignLeft, modelPriemnica2->item(row, 1)->text() +" - "+modelPriemnica2->item(row, 2)->text());break;
				case 2: painter.drawText(relX(128), relY(100 + 6 * (row - pagefrom)), relX(16), relY(9), Qt::AlignRight, modelPriemnica2->item(row, 4)->text());break;
				case 3: painter.drawText(relX(146), relY(100 + 6 * (row - pagefrom)), relX(16), relY(9), Qt::AlignLeft, modelPriemnica2->item(row, 3)->text());break;
				case 4: painter.drawText(relX(163), relY(100 + 6 * (row - pagefrom)), relX(16), relY(9), Qt::AlignRight, modelPriemnica2->item(row, 5)->text());break;
				case 5: 
					float iznos = modelPriemnica2->item(row, 4)->text().toFloat() * modelPriemnica2->item(row, 5)->text().toFloat(); 
					painter.drawText(relX(184), relY(100 + 6 * (row - pagefrom)), relX(15), relY(9), Qt::AlignRight, QString::number(iznos, 'f', 2));break;

				}
			}
		}
	}
	if( page < maxpage-1 )
		printer->newPage();
	}
}


void sterna::drawLagerLista(QPrinter *printer,QPainter& painter)
{
	int maxpage = 1;
	for( int page=0; page<maxpage; page++)
	{
		QFont f;
		QPainterPath path;

		f.setPointSize(12);
		painter.setFont(f);
		painter.drawText(relX(0), relY(3), relX(210), relY(6), Qt::AlignCenter, moi_firma_info1);

		f.setPointSize(10);
		painter.setFont(f);
		painter.drawText(relX(0), relY(6), relX(210), relY(9), Qt::AlignCenter, moi_firma_info2);
        
//         QPixmap image1(":/sterna/Resources/microsoft_logo.png");
//         painter.drawPixmap(relX(90), relY(20), relX(30), relX(20), image1);

		f.setPointSize(18);
		painter.setFont(f);
		painter.drawText(relX(0), relY(20), relX(210), relY(30), Qt::AlignCenter, trUtf8("Лагер Листа"));
		f.setPointSize(8);


		painter.drawRoundedRect(relX(20), relY(40), relX(180), relY(220), relX(2), relY(2), Qt::AbsoluteSize );
		path.moveTo(relX(20),relY(45));
		path.lineTo(relX(200),relY(45));

		path.moveTo(relX(30),relY(40));
		path.lineTo(relX(30),relY(260));

		path.moveTo(relX(100),relY(40));
		path.lineTo(relX(100),relY(260));

		path.moveTo(relX(125),relY(40));
		path.lineTo(relX(125),relY(260));

		path.moveTo(relX(150),relY(40));
		path.lineTo(relX(150),relY(260));

		path.moveTo(relX(175),relY(40));
		path.lineTo(relX(175),relY(260));

		f.setPointSize(8);
		painter.setFont(f);
		painter.drawText(relX(22), relY(44), trUtf8("Рб."));
		painter.drawText(relX(32), relY(44), trUtf8("Опис на артикли"));

		painter.drawText(relX(105), relY(44), trUtf8("Ед.мера"));
		painter.drawText(relX(130), relY(44), trUtf8("Влез"));
		painter.drawText(relX(155), relY(44), trUtf8("Излез"));
		painter.drawText(relX(180), relY(44), trUtf8("Салдо"));
		path.moveTo(relX(20),relY(275));
		path.lineTo(relX(70),relY(275));
		path.moveTo(relX(140),relY(275));
		path.lineTo(relX(190),relY(275));
		painter.drawText(relX(25), relY(280), trUtf8("Предал"));
		painter.drawText(relX(145), relY(280), trUtf8("Примил"));


		painter.drawPath(path);
		QStandardItemModel * modelIspratnica2 = m_mylager->getModel();
		if (modelIspratnica2)
		{
			int maxRowPage = 35;
			maxpage = (modelIspratnica2->rowCount() - 1) / (maxRowPage) + 1 ;
			int pagefrom = page * maxRowPage;
			int pageto = (page + 1) * maxRowPage < modelIspratnica2->rowCount() ? (page + 1) * maxRowPage : modelIspratnica2->rowCount();

			for (int row = pagefrom; row < pageto; row++)
			{
				for (int col = 0; col < modelIspratnica2->columnCount(); col++)
				{
					switch (col)
					{
					case 0: painter.drawText(relX(21), relY(50 + 6 * (row - pagefrom)), relX(8), relY(9), Qt::AlignLeft, QString::number(row + 1, 10));break;
					case 1: painter.drawText(relX(31), relY(50 + 6 * (row - pagefrom)), relX(70), relY(9), Qt::AlignLeft,  modelIspratnica2->item(row, 1)->text());break;
					case 2: painter.drawText(relX(101), relY(50 + 6 * (row - pagefrom)), relX(24), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 2)->text());break;
					case 4: painter.drawText(relX(125), relY(50 + 6 * (row - pagefrom)), relX(24), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 4)->text());break;
					case 5: painter.drawText(relX(150), relY(50 + 6 * (row - pagefrom)), relX(24), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 5)->text());break;
					case 6: painter.drawText(relX(175), relY(50 + 6 * (row - pagefrom)), relX(24), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 6)->text());break;
					}
				}
			}
		}
		if( page < maxpage-1 )
			printer->newPage();
	}
}

void sterna::drawAnalitikaArtikli(QPrinter *printer,QPainter& painter)
{
    int maxpage = 1;
    for( int page=0; page<maxpage; page++)
    {
        QFont f;
        QPainterPath path;


        f.setPointSize(10);
        painter.setFont(f);
        painter.drawText(relX(10), relY(15), relX(270), relY(5), Qt::AlignCenter, trUtf8("МАТЕРИЈАЛНА ЕВИДЕНЦИЈА ВО ТРГОВИЈА НА ГОЛЕМО"));
        f.setPointSize(8);
        
        painter.setFont(f);
        painter.drawText(relX(10), relY(15), relX(277), relY(5), Qt::AlignLeft, trUtf8("Трговец"));
        painter.drawText(relX(30), relY(15), relX(100), relY(5), Qt::AlignLeft, trUtf8("Оффице и Ко ДОО"));

        path.moveTo(relX(30),relY(18));
        path.lineTo(relX(80),relY(18));

        painter.drawText(relX(10), relY(20), relX(277), relY(5), Qt::AlignLeft, trUtf8("Адреса"));
		painter.drawText(relX(30), relY(20), relX(100), relY(5), Qt::AlignLeft, trUtf8("Св. Кирил и Методиј бр.50"));

		path.moveTo(relX(30),relY(23));
        path.lineTo(relX(80),relY(23));

        painter.drawText(relX(10), relY(25), relX(277), relY(5), Qt::AlignLeft, trUtf8("Место"));
		painter.drawText(relX(30), relY(25), relX(100), relY(5), Qt::AlignLeft, trUtf8("1000 Скопје"));

		path.moveTo(relX(30),relY(28));
        path.lineTo(relX(80),relY(28));

        painter.drawText(relX(10), relY(30), relX(277), relY(5), Qt::AlignLeft, trUtf8("Едб"));
		painter.drawText(relX(30), relY(30), relX(100), relY(5), Qt::AlignLeft, trUtf8("4030998346429"));

		path.moveTo(relX(30),relY(33));
        path.lineTo(relX(80),relY(33));
        
        ////////////////////////////////////////////////////////////////////////////////////////////////////////

        painter.setFont(f);
        painter.drawText(relX(220), relY(15), relX(67), relY(5), Qt::AlignLeft, trUtf8("____________________________"));
        painter.drawText(relX(220), relY(20), relX(67), relY(5), Qt::AlignLeft, trUtf8("Продажна Цена"));
        painter.drawText(relX(220), relY(25), relX(67), relY(5), Qt::AlignLeft, trUtf8("____________________________"));
        painter.drawText(relX(220), relY(30), relX(67), relY(5), Qt::AlignLeft, trUtf8("Едм:   ") +  m_analitikaArtikli->getModelInfo2());


        ////////////////////////////////////////////////////////////////////////////////////////////////////////
        QString m_proizvod = m_analitikaArtikli->getModelInfo();
        painter.drawText(relX(90), relY(25), relX(160), relY(5), Qt::AlignLeft, trUtf8("Назив на производот:" ));
        painter.drawText(relX(130), relY(25), relX(100), relY(5), Qt::AlignLeft, m_proizvod);
        path.moveTo(relX(130),relY(28));
        path.lineTo(relX(200),relY(28));

        painter.drawText(relX(90), relY(30), relX(60), relY(5), Qt::AlignLeft, trUtf8("Магацин-стовариште"));
		painter.drawText(relX(130), relY(30), relX(100), relY(5), Qt::AlignLeft, trUtf8("Ратко Митровиќ бб нас. Драчево"));

		path.moveTo(relX(130),relY(33));
        path.lineTo(relX(200),relY(33));

        ////////////////////////////////////////////////////////////////////////////////////////////////////////

        painter.drawRoundedRect(relX(10), relY(40), relX(277), relY(140), relX(2), relY(2), Qt::AbsoluteSize );
        path.moveTo(relX(45),relY(45));
        path.lineTo(relX(287),relY(45));
        path.moveTo(relX(10),relY(55));
        path.lineTo(relX(287),relY(55));
        path.moveTo(relX(10),relY(60));
        path.lineTo(relX(287),relY(60));

        painter.drawText(relX(12), relY(50), trUtf8("Рб."));
        painter.drawText(relX(12), relY(58), trUtf8("1"));

        //reden broj.
        path.moveTo(relX(20),relY(40));
        path.lineTo(relX(20),relY(180));
        painter.drawText(relX(22), relY(50), trUtf8("Дат.книжење"));
        painter.drawText(relX(22), relY(58), trUtf8("2"));

        //datum na knizenje
        path.moveTo(relX(45),relY(40));
        path.lineTo(relX(45),relY(180));
        painter.drawText(relX(47), relY(43), trUtf8("Книговодствен документ"));
        painter.drawText(relX(47), relY(50), trUtf8("Бр. документ"));
        painter.drawText(relX(47), relY(58), trUtf8("3"));

        //broj na dokument
        path.moveTo(relX(70),relY(45));
        path.lineTo(relX(70),relY(180));
        painter.drawText(relX(72), relY(50), trUtf8("Дат. на док."));
        painter.drawText(relX(72), relY(58), trUtf8("4"));
       

        //naziv na dokument
        path.moveTo(relX(95),relY(45));
        path.lineTo(relX(95),relY(180));
        painter.drawText(relX(97), relY(50), trUtf8("Назив Док."));
        painter.drawText(relX(97), relY(58), trUtf8("5"));

        //vlez
        path.moveTo(relX(170),relY(40));
        path.lineTo(relX(170),relY(180));
        painter.drawText(relX(172), relY(43), trUtf8("Количина"));
        painter.drawText(relX(172), relY(50), trUtf8("Влез"));
        painter.drawText(relX(172), relY(58), trUtf8("6"));

        //izlez
        path.moveTo(relX(209),relY(45));
        path.lineTo(relX(209),relY(180));
        painter.drawText(relX(211), relY(50), trUtf8("Излез"));
        painter.drawText(relX(211), relY(58), trUtf8("7"));

        //sostojba
        path.moveTo(relX(248),relY(45));
        path.lineTo(relX(248),relY(180));
        painter.drawText(relX(250), relY(50), trUtf8("Состојба"));
        painter.drawText(relX(250), relY(58), trUtf8("8"));

        f.setPointSize(8);
        painter.setFont(f);



        painter.drawText(relX(10), relY(190), trUtf8("Образец МЕТГ"));
        painter.drawText(relX(145), relY(190), trUtf8("(М.П.)"));
        painter.drawText(relX(237), relY(195), trUtf8("Потпис на овластено лице"));
        path.moveTo(relX(237),relY(190));
        path.lineTo(relX(287),relY(190));


        painter.drawPath(path);
        QStandardItemModel * modelIspratnica2 = m_analitikaArtikli->getModel();
        if (modelIspratnica2)
        {
            int maxRowPage = 20;
            maxpage = modelIspratnica2->rowCount() / (maxRowPage ) + 1;
            int pagefrom = page * maxRowPage;
            int pageto = (page + 1) * maxRowPage < modelIspratnica2->rowCount() ? (page + 1) * maxRowPage : modelIspratnica2->rowCount();

            for (int row = pagefrom; row < pageto; row++)
            {
                for (int col = 0; col < modelIspratnica2->columnCount() + 2; col++)
                {
                    switch (col)
                    {
                    case 0: painter.drawText(relX(11), relY(61 + 6 * (row - pagefrom)), relX(8), relY(9), Qt::AlignLeft, QString::number(row + 1, 10));break;
                    case 1: painter.drawText(relX(21), relY(61 + 6 * (row - pagefrom)), relX(23), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 0)->text().left(10));break;
                    case 2: painter.drawText(relX(47), relY(61 + 6 * (row - pagefrom)), relX(23), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 1)->text());break;
                    case 4: painter.drawText(relX(71), relY(61 + 6 * (row - pagefrom)), relX(23), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 2)->text().left(10));break;
                    case 5: painter.drawText(relX(96), relY(61 + 6 * (row - pagefrom)), relX(93), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 3)->text());break;
                    case 6: painter.drawText(relX(171), relY(61 + 6 * (row - pagefrom)), relX(37), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 4)->text());break;
                    case 7: painter.drawText(relX(210), relY(61 + 6 * (row - pagefrom)), relX(37), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 5)->text());break;
                    case 8: painter.drawText(relX(249), relY(61 + 6 * (row - pagefrom)), relX(37), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 6)->text());break;
                    }
                }
            }
        }
        if( page < maxpage-1 )
            printer->newPage();
    }
}
void sterna::drawAnalitikaKomintenti(QPrinter *printer,QPainter& painter)
{
	int maxpage = 1;
	for( int page=0; page<maxpage; page++)
	{
		QFont f;
		QPainterPath path;

		f.setPointSize(12);
		painter.setFont(f);
		painter.drawText(relX(0), relY(3), relX(210), relY(6), Qt::AlignCenter, moi_firma_info1);

		f.setPointSize(10);
		painter.setFont(f);
		painter.drawText(relX(0), relY(6), relX(210), relY(9), Qt::AlignCenter, moi_firma_info2);

		//         QPixmap image1(":/sterna/Resources/microsoft_logo.png");
		//         painter.drawPixmap(relX(90), relY(20), relX(30), relX(20), image1);

		f.setPointSize(12);
		painter.setFont(f);
		painter.drawText(relX(0), relY(20), relX(210), relY(30), Qt::AlignCenter, trUtf8("Аналитика по Коминтент:") + m_analitikaKomintenti->getModelInfo());
		f.setPointSize(8);


		painter.drawRoundedRect(relX(20), relY(40), relX(180), relY(220), relX(2), relY(2), Qt::AbsoluteSize );
		path.moveTo(relX(20),relY(45));
		path.lineTo(relX(200),relY(45));

		path.moveTo(relX(30),relY(40));
		path.lineTo(relX(30),relY(260));

		path.moveTo(relX(60),relY(40));
		path.lineTo(relX(60),relY(260));

		path.moveTo(relX(125),relY(40));
		path.lineTo(relX(125),relY(260));

		path.moveTo(relX(150),relY(40));
		path.lineTo(relX(150),relY(260));

		path.moveTo(relX(175),relY(40));
		path.lineTo(relX(175),relY(260));

		f.setPointSize(8);
		painter.setFont(f);
		painter.drawText(relX(22), relY(44), trUtf8("Рб."));
		painter.drawText(relX(32), relY(44), trUtf8("Вид док."));
		painter.drawText(relX(62), relY(44), trUtf8("Артикал"));
		painter.drawText(relX(130), relY(44), trUtf8("Датум"));
		painter.drawText(relX(155), relY(44), trUtf8("Количина"));
		painter.drawText(relX(180), relY(44), trUtf8("Цена"));
		path.moveTo(relX(20),relY(275));
		path.lineTo(relX(70),relY(275));
		path.moveTo(relX(140),relY(275));
		path.lineTo(relX(190),relY(275));
		painter.drawText(relX(25), relY(280), trUtf8("Предал"));
		painter.drawText(relX(145), relY(280), trUtf8("Примил"));


		painter.drawPath(path);
		QStandardItemModel * modelIspratnica2 = m_analitikaKomintenti->getModel();
		if (modelIspratnica2)
		{
			int maxRowPage = 35;
			maxpage = modelIspratnica2->rowCount() / (maxRowPage + 1) + 1;
			int pagefrom = page * maxRowPage;
			int pageto = (page + 1) * maxRowPage < modelIspratnica2->rowCount() ? (page + 1) * maxRowPage : modelIspratnica2->rowCount();

			for (int row = pagefrom; row < pageto; row++)
			{
				for (int col = 0; col < modelIspratnica2->columnCount(); col++)
				{
					switch (col)
					{
					case 0: painter.drawText(relX(21), relY(50 + 6 * (row - pagefrom)), relX(8), relY(9), Qt::AlignLeft, QString::number(row + 1, 10));break;
					case 1: painter.drawText(relX(31), relY(50 + 6 * (row - pagefrom)), relX(30), relY(9), Qt::AlignLeft,  modelIspratnica2->item(row, 0)->text() + " - " +modelIspratnica2->item(row, 1)->text());break;
					case 2: painter.drawText(relX(61), relY(50 + 6 * (row - pagefrom)), relX(64), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 3)->text());break;
					case 4: painter.drawText(relX(125), relY(50 + 6 * (row - pagefrom)), relX(25), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 2)->text().left(10));break;
					case 5: painter.drawText(relX(150), relY(50 + 6 * (row - pagefrom)), relX(24), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 4)->text());break;
					case 6: painter.drawText(relX(175), relY(50 + 6 * (row - pagefrom)), relX(24), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 5)->text());break;
					}
				}
			}
		}
		if( page < maxpage-1 )
			printer->newPage();
	}
}
void sterna::drawArtikliLista(QPrinter *printer, QPainter& painter)
{
	int maxpage = 2;
	for( int page=0; page<maxpage; page++)
	{
	QFont f;
	QPainterPath path;

	f.setPointSize(12);
	painter.setFont(f);
	painter.drawText(relX(0), relY(3), relX(210), relY(6), Qt::AlignCenter, moi_firma_info1);
	f.setPointSize(10);
	painter.setFont(f);
	painter.drawText(relX(0), relY(6), relX(210), relY(9), Qt::AlignCenter, moi_firma_info2);

	f.setPointSize(20);
	painter.setFont(f);
	painter.drawText(relX(0), relY(12), relX(210), relY(9), Qt::AlignCenter, 
		trUtf8("Листа на артикли"));

    QPixmap image1(moi_logo);
    painter.drawPixmap(relX(90), relY(20), relX(30), relX(20), image1);

	painter.drawRoundedRect(relX(20), relY(40), relX(180), relY(230), relX(2), relY(2), Qt::AbsoluteSize );
	path.moveTo(relX(20),relY(45));
	path.lineTo(relX(200),relY(45));

	path.moveTo(relX(30),relY(40));
	path.lineTo(relX(30),relY(270));

	path.moveTo(relX(110),relY(40));
	path.lineTo(relX(110),relY(270));

	path.moveTo(relX(125),relY(40));
	path.lineTo(relX(125),relY(270));

	path.moveTo(relX(145),relY(40));
	path.lineTo(relX(145),relY(270));

	path.moveTo(relX(160),relY(40));
	path.lineTo(relX(160),relY(270));

	path.moveTo(relX(175),relY(40));
	path.lineTo(relX(175),relY(270));

	f.setPointSize(8);
	painter.setFont(f);
	painter.drawText(relX(22), relY(44), trUtf8("Рб."));
	painter.drawText(relX(32), relY(44), trUtf8("Опис на артикал - услуга"));
	painter.drawText(relX(115), relY(44), trUtf8("Кол."));
	painter.drawText(relX(130), relY(44), trUtf8("Цена"));
	painter.drawText(relX(150), relY(44), trUtf8("Износ"));
	painter.drawText(relX(165), relY(44), trUtf8("ДДВ"));
	painter.drawText(relX(180), relY(44), trUtf8("Вкупно"));

	path.moveTo(relX(20),relY(275));
	path.lineTo(relX(70),relY(275));
	path.moveTo(relX(140),relY(275));
	path.lineTo(relX(190),relY(275));
	painter.drawText(relX(25), relY(280), trUtf8("Изработил"));
	painter.drawText(relX(145), relY(280), trUtf8("Директор"));

	painter.drawPath(path);


	QStandardItemModel * modelArtikli = m_myartikli->getModel();
	if (modelArtikli)
	{
		int maxRowPage = 15;
		int pagefrom = page * maxRowPage;
		int pageto = (page + 1) * maxRowPage < modelArtikli->rowCount() ? (page + 1) * maxRowPage : modelArtikli->rowCount();

		for (int row = pagefrom; row < pageto; row++)
		{
			for (int col = 0; col < modelArtikli->columnCount(); col++)
			{
				switch (col)
				{
				case 0: painter.drawText(relX(21), relY(50 + 6 * (row - pagefrom)), relX(8), relY(9), Qt::AlignLeft, QString::number(row + 1, 10));break;
					case 1: painter.drawText(relX(31), relY(50 + 6 * (row - pagefrom)), relX(78), relY(9), Qt::AlignLeft, modelArtikli->item(row, col + 1)->text());break;
					case 2: painter.drawText(relX(111), relY(50 + 6 * (row - pagefrom)), relX(13), relY(9), Qt::AlignLeft, trUtf8("ул.Народен Фронт "));break;
					case 3: painter.drawText(relX(126), relY(50 + 6 * (row - pagefrom)), relX(18), relY(9), Qt::AlignRight, trUtf8("CCCC"));break;
					case 4: painter.drawText(relX(146), relY(50 + 6 * (row - pagefrom)), relX(13), relY(9), Qt::AlignRight, trUtf8("BBBB"));break;
					case 5: painter.drawText(relX(161), relY(50 + 6 * (row - pagefrom)), relX(13), relY(9), Qt::AlignRight, trUtf8("AAAA"));break;
				}
			}
		}
	}
	if( page < maxpage-1 )
		printer->newPage();
	}
}
void sterna::drawKomintentiLista(QPainter& painter)
{
	QFont f;
	QPainterPath path;

	f.setPointSize(12);
	painter.setFont(f);
	painter.drawText(relX(0), relY(3), relX(210), relY(6), Qt::AlignCenter, moi_firma_info1);
	f.setPointSize(10);
	painter.setFont(f);
	painter.drawText(relX(0), relY(6), relX(210), relY(9), Qt::AlignCenter, moi_firma_info2);

	f.setPointSize(20);
	painter.setFont(f);
	painter.drawText(relX(0), relY(12), relX(210), relY(9), Qt::AlignCenter, 
		trUtf8("Листа на коминтенти"));

    QPixmap image1(moi_logo);
    painter.drawPixmap(relX(90), relY(20), relX(30), relX(20), image1);

	painter.drawRoundedRect(relX(20), relY(40), relX(180), relY(230), relX(2), relY(2), Qt::AbsoluteSize );
	path.moveTo(relX(20),relY(45));
	path.lineTo(relX(200),relY(45));

	path.moveTo(relX(30),relY(40));
	path.lineTo(relX(30),relY(270));

	path.moveTo(relX(110),relY(40));
	path.lineTo(relX(110),relY(270));

	path.moveTo(relX(125),relY(40));
	path.lineTo(relX(125),relY(270));

	path.moveTo(relX(145),relY(40));
	path.lineTo(relX(145),relY(270));

	path.moveTo(relX(160),relY(40));
	path.lineTo(relX(160),relY(270));

	path.moveTo(relX(175),relY(40));
	path.lineTo(relX(175),relY(270));

	f.setPointSize(8);
	painter.setFont(f);
	painter.drawText(relX(22), relY(44), trUtf8("Рб."));
	painter.drawText(relX(32), relY(44), trUtf8("Опис на артикал - услуга"));
	painter.drawText(relX(115), relY(44), trUtf8("Кол."));
	painter.drawText(relX(130), relY(44), trUtf8("Цена"));
	painter.drawText(relX(150), relY(44), trUtf8("Износ"));
	painter.drawText(relX(165), relY(44), trUtf8("ДДВ"));
	painter.drawText(relX(180), relY(44), trUtf8("Вкупно"));

	path.moveTo(relX(20),relY(275));
	path.lineTo(relX(70),relY(275));
	path.moveTo(relX(140),relY(275));
	path.lineTo(relX(190),relY(275));
	painter.drawText(relX(25), relY(280), trUtf8("Изработил"));
	painter.drawText(relX(145), relY(280), trUtf8("Директор"));

	painter.drawPath(path);
}


QString sterna::convertIntToText(int& num)
{
	QString t = trUtf8("Со зборови: ");
	int m = 0;
	int i = 0;
	int s = 0;
	int d = 0;
	int e = 0;
	m = num / qPow(10,6);
	num = num - m * qPow(10,6);
	i = num / qPow(10,3);
	num = num - i * qPow(10,3);
	s = num;
	if (m)
	{
		QString temp = (m == 1) ? trUtf8("милион") : trUtf8("милиони");
		t += convertSToText(m) + temp;
	}
	if (i)
	{
		t += convertSToText(i) + trUtf8("илјади");
	}
	t += (m || i) && e ? trUtf8("и") : "";
	if (s)
	{
		t += convertSToText(s) + trUtf8("денари");
	}
	return t;

}

void sterna::updateNavigator(QWidget* a, QWidget* b)
{
    b->setFocus();
    closeMyWidget();
    a->setFocus();
    m_left->updateSelection(a);
	ui.actionPrinter->setEnabled(false);
}

QString sterna::convertSToText(int& num)
{
	QString ss = "";
	int s = 0;
	int d = 0;
	int e = 0;
	s = num / qPow(10,2);
	num = num - s * qPow(10,2);
	if (num > 20)
	{
		d = num / qPow(10,1);
		num = num - d * qPow(10,1);
		e = num;
	}
	else
	{
		d = 0;
		e = num;
	}
	switch (s)
	{
	case 0: ss += (""); break; 
	case 1: ss += trUtf8("сто");; break; 
	case 2: ss += trUtf8("двеста"); break; 
	case 3: ss += trUtf8("триста"); break; 
	case 4: ss += trUtf8("четрсто"); break; 
	case 5: ss += trUtf8("петсто"); break; 
	case 6: ss += trUtf8("шесто"); break; 
	case 7: ss += trUtf8("седумсто"); break; 
	case 8: ss += trUtf8("осумсто"); break; 
	case 9: ss += trUtf8("деветсто"); break; 
	}
	switch (d)
	{
	case 0: ss += (""); break; 
	case 2: ss += trUtf8("дваесет");; break; 
	case 3: ss += trUtf8("триесет");; break; 
	case 4: ss += trUtf8("четириесет");; break; 
	case 5: ss += trUtf8("педесет");; break; 
	case 6: ss += trUtf8("шеесет");; break; 
	case 7: ss += trUtf8("седумдесет");; break; 
	case 8: ss += trUtf8("осумдесет");; break; 
	case 9: ss += trUtf8("деведесет");; break; 
	}
	ss += (s || d) && e ? trUtf8("и") : "";
	switch (e)
	{
	case 0: ss += (""); break; 
	case 1: ss += trUtf8("еден"); break; 
	case 2: ss += trUtf8("два"); break; 
	case 3: ss += trUtf8("три"); break; 
	case 4: ss += trUtf8("четири"); break; 
	case 5: ss += trUtf8("пет"); break; 
	case 6: ss += trUtf8("шест"); break; 
	case 7: ss += trUtf8("седум"); break; 
	case 8: ss += trUtf8("осум"); break; 
	case 9: ss += trUtf8("девет"); break; 
	case 10: ss += trUtf8("десет"); break; 
	case 11: ss += trUtf8("единаесет"); break; 
	case 12: ss += trUtf8("дванаесет"); break; 
	case 13: ss += trUtf8("тринаесет"); break; 
	case 14: ss += trUtf8("четиринаесет"); break; 
	case 15: ss += trUtf8("петнаесет"); break; 
	case 16: ss += trUtf8("шеснаесет"); break; 
	case 17: ss += trUtf8("седумнаесет"); break; 
	case 18: ss += trUtf8("осумнаесет"); break; 
	case 19: ss += trUtf8("деветнаесет"); break; 
	case 20: ss += trUtf8("дваесет"); break; 
	}
	return ss;
}


void sterna::drawIzjava(QPrinter *printer, QPainter& painter)
{
		painter.begin(printer);
		QFont f;
		QLocale loc;
		f.setPointSize(8);

		QPen pen;  // creates a default pen
		pen.setStyle(Qt::DashDotLine);
		pen.setWidth(3);
		painter.setPen(pen);
		painter.drawLine (relX(0), relY(148), relX(210), relY(148));
		pen.setStyle(Qt::SolidLine);
		pen.setWidth(3);
		painter.setPen(pen);
		
		QPixmap image1(moi_nozici);
		painter.drawPixmap(relX(5), relY(146), relX(6), relX(4), image1);

		int pOffset = 148;
		for (int rr = 0; rr < 2; rr++)
		{
			painter.drawRoundedRect(relX(10), relY(30 + rr * pOffset), relX(100), relY(107), relX(0), relY(0), Qt::AbsoluteSize );
			for (int i = 0; i < 20; i++)
			{
				painter.drawLine (relX(10), relY(37 + i * 5 + rr * pOffset), relX(110), relY(37 + i * 5 + rr * pOffset));
			}
			painter.drawLine (relX(15), relY(30 + rr * pOffset), relX(15), relY(137 -15 + rr * pOffset));
			painter.drawLine (relX(60), relY(30 + rr * pOffset), relX(60), relY(137 + rr * pOffset));
			painter.drawLine (relX(75), relY(30 + rr * pOffset), relX(75), relY(137 + rr * pOffset));
			painter.drawLine (relX(90), relY(30 + rr * pOffset), relX(90), relY(137 + rr * pOffset));

			f.setPointSize(7);
			painter.setFont(f);		

			painter.drawText(relX(10), relY(30 + rr * pOffset), relX(5), relY(7), Qt::AlignCenter, trUtf8("Рб."));
			painter.drawText(relX(15), relY(30 + rr * pOffset), relX(45), relY(7), Qt::AlignCenter, trUtf8("Отпадни материјали"));
			painter.drawText(relX(60), relY(30 + rr * pOffset), relX(15), relY(7), Qt::AlignCenter, trUtf8("Вк.кгр"));
			painter.drawText(relX(75), relY(30 + rr * pOffset), relX(15), relY(7), Qt::AlignCenter, trUtf8("Цена."));
			painter.drawText(relX(90), relY(30 + rr * pOffset), relX(20), relY(7), Qt::AlignCenter, trUtf8("ВКУПНО."));

			f.setPointSize(7);
			painter.setFont(f);		
			
			for (int rr = 0; rr < 2; rr++)
			{
				for (int i = 0; i < 17; i++)
				{
					painter.drawText(relX(10), relY(37 + i * 5 + rr * pOffset), relX(5), relY(5), Qt::AlignCenter, QString::number(i + 1 , 10) +".");
				}
			}
		}



		f.setPointSize(8);
		painter.setFont(f);

		QStringList modelIzjavaInfo = m_myizjava->getIzjavaInfo();
		float iznos = 0.f;
		QStandardItemModel * modelIzjava2 = m_myizjava->getModel();

		for (int i = 0; i < 2; i++)
		{

			f.setPointSize(12);
			f.setBold(true);	
			painter.setFont(f);
			painter.drawText(relX(10), relY(148 * i + 10), moi_firma_info1);
			f.setPointSize(8);
			f.setBold(false);	
			painter.setFont(f);
			painter.drawText(relX(10), relY(148 * i + 14), moi_firma_banka1);
			painter.drawText(relX(10), relY(148 * i + 18), moi_firma_edb);
			
			QString kantarnaIzjavaText = trUtf8("КАНТАРНО-КАСА ИСПЛАТИ Бр. ") + modelIzjavaInfo.at(3);
			painter.drawText(relX(10), relY(148 * i + 26), kantarnaIzjavaText);

			f.setPointSize(12);
			painter.setFont(f);
			QString izjavaText = trUtf8("ИЗЈАВА Број ") + modelIzjavaInfo.at(3);
			painter.drawText(relX(125), relY(148 * i + 25), izjavaText);
			f.setPointSize(8);
			painter.setFont(f);

			painter.drawText(relX(115), relY(148 * i + 35), trUtf8("Јас долупотпишаниот_____________________________________"));
			painter.drawText(relX(145), relY(148 * i + 32), relX(50), relY(5), Qt::AlignLeft, modelIzjavaInfo.at(0));

			painter.drawText(relX(115), relY(148 * i + 45), trUtf8("ЕМБГ_________________________________со место на живеење"));
			painter.drawText(relX(125), relY(148 * i + 42), relX(50), relY(5), Qt::AlignLeft, modelIzjavaInfo.at(5));
			
			painter.drawText(relX(115), relY(148 * i + 55), trUtf8("во град(с)____________________општина___________________"));
			painter.drawText(relX(130), relY(148 * i + 52), relX(50), relY(5), Qt::AlignLeft, modelIzjavaInfo.at(2));

			painter.drawText(relX(115), relY(148 * i + 65), trUtf8("лична карта_____________________________________________"));
			painter.drawText(relX(135), relY(148 * i + 62), relX(50), relY(5), Qt::AlignLeft, modelIzjavaInfo.at(6));

			painter.drawText(relX(115), relY(148 * i + 75), moi_izjava1);
			painter.drawText(relX(115), relY(148 * i + 85), moi_izjava2);
			painter.drawText(relX(115), relY(148 * i + 95), trUtf8("________________________________________________________"));
			painter.drawText(relX(115), relY(148 * i + 105), trUtf8("На ") + moi_firma_info1);
			painter.drawText(relX(115), relY(148 * i + 110), moi_firma_banka1);
			painter.drawText(relX(115), relY(148 * i + 115), moi_firma_edb);

			painter.drawText(relX(115), relY(148 * i + 123), trUtf8("________________"));
			painter.drawText(relX(115), relY(148 * i + 120), relX(50), relY(5), Qt::AlignLeft, modelIzjavaInfo.at(4));
			painter.drawText(relX(115), relY(148 * i + 126), trUtf8("Дата"));

			painter.drawText(relX(115), relY(148 * i + 135), trUtf8("________________________________"));
			painter.drawText(relX(115), relY(148 * i + 138), trUtf8("Изјавувач"));

			float vkupno = 0.f;
			if (modelIzjava2)
			{
				for (int row = 0; row < modelIzjava2->rowCount(); row++)
				{
					painter.drawText(relX(16), relY(148 * i + 38 + row * 5), relX(30), relY(5), Qt::AlignLeft, modelIzjava2->item(row, 2)->text());
					painter.drawText(relX(60), relY(148 * i + 38 + row * 5), relX(14), relY(5), Qt::AlignRight, modelIzjava2->item(row, 4)->text());
					painter.drawText(relX(75), relY(148 * i + 38 + row * 5), relX(14), relY(5), Qt::AlignRight, modelIzjava2->item(row, 5)->text());
					iznos = loc.toFloat( modelIzjava2->item(row, 4)->text()) * loc.toFloat( modelIzjava2->item(row, 5)->text());
					vkupno += iznos;
					painter.drawText(relX(90), relY(148 * i + 38 + row * 5), relX(19), relY(5), Qt::AlignRight, loc.toString( iznos, 'f', 2));
				}
			}
			painter.drawText(relX(16), relY(148 * i + 123), relX(19), relY(5), Qt::AlignRight, trUtf8("ЗБИР:"));
			painter.drawText(relX(16), relY(148 * i + 128), relX(19), relY(5), Qt::AlignRight, trUtf8("ДДВ:"));
			painter.drawText(relX(16), relY(148 * i + 133), relX(19), relY(5), Qt::AlignRight, trUtf8("Вкупно:"));

			painter.drawText(relX(90), relY(148 * i + 123), relX(19), relY(5), Qt::AlignRight, loc.toString( vkupno, 'f', 2));
			painter.drawText(relX(90), relY(148 * i + 128), relX(19), relY(5), Qt::AlignRight, loc.toString( 0.f, 'f', 2));
			painter.drawText(relX(90), relY(148 * i + 133), relX(19), relY(5), Qt::AlignRight, loc.toString( vkupno, 'f', 2));

		}
		painter.end();
}


void sterna::drawDnevenIzvestaj(QPrinter *printer,QPainter& painter)
{
	int maxpage = 1;
	for( int page=0; page<maxpage; page++)
	{
		QFont f;
		QPainterPath path;

		f.setPointSize(12);
		painter.setFont(f);
		painter.drawText(relX(0), relY(3), relX(210), relY(6), Qt::AlignCenter, moi_firma_info1);

		f.setPointSize(10);
		painter.setFont(f);
		painter.drawText(relX(0), relY(6), relX(210), relY(9), Qt::AlignCenter, moi_firma_info2);

		//         QPixmap image1(":/sterna/Resources/microsoft_logo.png");
		//         painter.drawPixmap(relX(90), relY(20), relX(30), relX(20), image1);

		f.setPointSize(14);
		painter.setFont(f);
		painter.drawText(relX(0), relY(15), relX(210), relY(20), Qt::AlignCenter, trUtf8("Дневен извештај за промет на артикли и услуги"));
		QString temp = trUtf8("на ден ") + m_dnevenpromet->getDatum();
		painter.drawText(relX(0), relY(20), relX(210), relY(25), Qt::AlignCenter, temp);

		f.setPointSize(8);


		painter.drawRoundedRect(relX(20), relY(40), relX(180), relY(220), relX(2), relY(2), Qt::AbsoluteSize );
		path.moveTo(relX(20),relY(45));
		path.lineTo(relX(200),relY(45));

		path.moveTo(relX(30),relY(40));
		path.lineTo(relX(30),relY(260));

		path.moveTo(relX(100),relY(40));
		path.lineTo(relX(100),relY(260));

		path.moveTo(relX(125),relY(40));
		path.lineTo(relX(125),relY(260));

		path.moveTo(relX(150),relY(40));
		path.lineTo(relX(150),relY(260));

		path.moveTo(relX(175),relY(40));
		path.lineTo(relX(175),relY(260));

		f.setPointSize(8);
		painter.setFont(f);
		painter.drawText(relX(22), relY(44), trUtf8("Рб."));
		painter.drawText(relX(32), relY(44), trUtf8("Опис на артикли"));

		painter.drawText(relX(105), relY(44), trUtf8("Ед.мера"));
		painter.drawText(relX(130), relY(44), trUtf8("Влез"));
		painter.drawText(relX(155), relY(44), trUtf8("Излез"));
		painter.drawText(relX(180), relY(44), trUtf8("Салдо"));
		path.moveTo(relX(20),relY(275));
		path.lineTo(relX(70),relY(275));
		path.moveTo(relX(140),relY(275));
		path.lineTo(relX(190),relY(275));
		painter.drawText(relX(25), relY(280), trUtf8("Предал"));
		painter.drawText(relX(145), relY(280), trUtf8("Примил"));


		painter.drawPath(path);
		QStandardItemModel * modelIspratnica2 = m_dnevenpromet->getModel();
		if (modelIspratnica2)
		{
			int maxRowPage = 30;
			maxpage = modelIspratnica2->rowCount() / (maxRowPage + 1) + 1;
			int pagefrom = page * maxRowPage;
			int pageto = (page + 1) * maxRowPage < modelIspratnica2->rowCount() ? (page + 1) * maxRowPage : modelIspratnica2->rowCount();

			for (int row = pagefrom; row < pageto; row++)
			{
				for (int col = 0; col < modelIspratnica2->columnCount(); col++)
				{
					switch (col)
					{
					case 0: painter.drawText(relX(21), relY(50 + 6 * (row - pagefrom)), relX(8), relY(9), Qt::AlignLeft, QString::number(row + 1, 10));break;
					case 1: painter.drawText(relX(31), relY(50 + 6 * (row - pagefrom)), relX(70), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 1)->text());break;
					case 2: painter.drawText(relX(101), relY(50 + 6 * (row - pagefrom)), relX(24), relY(9), Qt::AlignLeft, modelIspratnica2->item(row, 2)->text());break;
					case 3: painter.drawText(relX(125), relY(50 + 6 * (row - pagefrom)), relX(24), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 3)->text());break;
					case 4: painter.drawText(relX(150), relY(50 + 6 * (row - pagefrom)), relX(24), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 4)->text());break;
					case 5: painter.drawText(relX(175), relY(50 + 6 * (row - pagefrom)), relX(24), relY(9), Qt::AlignRight, modelIspratnica2->item(row, 5)->text());break;
					}
				}
			}
		}
		if( page < maxpage-1 )
			printer->newPage();
	}
}    
void sterna::drawTovarenList(QPrinter *printer, QPainter& painter)
{
    QLocale loc;
    int maxpage = 1;
    float suma = 0.0f;
    float ddv = 0.0f;
    float sumaDDV = 0.0f;
    QStringList modelIspratnicaInfo = m_myispratnici->getIspratnicaInfo();
    QFont f;

    f.setPointSize(14);
    painter.setFont(f);
    painter.drawText(relX(10), relY(20), trUtf8("ТОВАРЕН ЛИСТ ЗА ВНАТРЕШЕН ПРЕВОЗ НА СТОКА БР:  ")+ modelIspratnicaInfo.at(4));
    f.setPointSize(8);

    painter.setFont(f);
//     painter.drawText(relX(160), relY(78), relX(40), relY(65), Qt::AlignRight, trUtf8("Сериски Број: ") + modelIspratnicaInfo.at(4));
//     painter.drawText(relX(160), relY(81), relX(40), relY(70), Qt::AlignRight, trUtf8("Датум: ") + modelIspratnicaInfo.at(3));
//     painter.drawText(relX(160), relY(84), relX(40), relY(75), Qt::AlignRight, trUtf8("Валута: ") + modelIspratnicaInfo.at(3));
    //         painter.drawRoundedRect(relX(20), relY(55), relX(80), relY(30), relX(3), relY(3), Qt::AbsoluteSize );
//    painter.drawText(relX(25), relY(70), trUtf8("До:"));




    painter.drawRoundedRect(relX(10), relY(30), relX(190), relY(260), relX(2), relY(2), Qt::AbsoluteSize );
    painter.drawText(relX(12), relY(34), trUtf8("1. Испраќач - Продавач"));
    painter.drawText(relX(12), relY(38), trUtf8("  ( име, адреса, место )"));

    f.setPointSize(10);
    painter.setFont(f);
    painter.drawText(relX(80), relY(34), trUtf8(" ОФИС и КО"));
    painter.drawText(relX(80), relY(38), trUtf8(" ул.Св. Кирил и Методиј бр.50 - Скопје  "));
    painter.drawText(relX(80), relY(42), trUtf8(" 1000 Скопје  "));

    f.setPointSize(8);
    painter.setFont(f);


    painter.drawLine(relX(10), relY(55), relX(200), relY(55));
    painter.drawText(relX(12), relY(59), trUtf8("2. Примач - Купувач"));
    painter.drawText(relX(12), relY(63), trUtf8("  ( име, адреса, место )"));
    f.setPointSize(10);
    painter.setFont(f);
    painter.drawText(relX(80), relY(60), modelIspratnicaInfo.at(0));
    painter.drawText(relX(80), relY(65), modelIspratnicaInfo.at(1));
    painter.drawText(relX(80), relY(70), modelIspratnicaInfo.at(2));
    f.setPointSize(8);
    painter.setFont(f);

    painter.drawLine(relX(10), relY(80), relX(200), relY(80));
    painter.drawText(relX(12), relY(84), trUtf8("3. Превозник"));
    painter.drawText(relX(12), relY(88), trUtf8("  ( име, адреса, место )"));

    f.setPointSize(10);
    painter.setFont(f);
    painter.drawText(relX(80), relY(84), trUtf8(" ОФИС и КО"));
    painter.drawText(relX(80), relY(88), trUtf8("  ул.Св. Кирил и Методиј бр.50 - Скопје  "));
    painter.drawText(relX(80), relY(92), trUtf8(" 1000 Скопје  "));

    f.setPointSize(8);
    painter.setFont(f);

    painter.drawLine(relX(10), relY(105), relX(200), relY(105));
    painter.drawText(relX(12), relY(109), trUtf8("4. Регистарски број на возилото"));
    f.setPointSize(10);
    painter.setFont(f);
    painter.drawText(relX(20), relY(116), trUtf8("SK 5882 AC"));
    painter.drawText(relX(20), relY(122), trUtf8("SK 348 SM"));
    painter.drawText(relX(20), relY(128), trUtf8("SK 998 JN"));
    f.setPointSize(8);
    painter.setFont(f);
    
    painter.drawLine(relX(10), relY(140), relX(200), relY(140));
    painter.drawLine(relX(105), relY(105), relX(105), relY(140));
    painter.drawText(relX(107), relY(110), trUtf8("5. Место и дата на утовар"));
    painter.drawText(relX(107), relY(115), trUtf8("   дата: ")+ modelIspratnicaInfo.at(3));
    painter.drawText(relX(107), relY(120), trUtf8("   место: Скопје"));
    painter.drawText(relX(107), relY(125), trUtf8("6. Место и дата на истовар"));
    painter.drawText(relX(107), relY(130), trUtf8("   дата: ") + modelIspratnicaInfo.at(3));
    painter.drawText(relX(107), relY(135), trUtf8("   место:") + modelIspratnicaInfo.at(2));


    painter.drawText(relX(12), relY(144), trUtf8("7. Податоци за стоката која се превезува"));
    painter.drawLine(relX(10), relY(145), relX(200), relY(145));
    painter.drawText(relX(12), relY(149), trUtf8("Ознака/број      Број пакети      Вид Амбалажа      Вид на стока"));
    painter.drawLine(relX(10), relY(180), relX(200), relY(180));
    painter.drawLine(relX(135), relY(145), relX(135), relY(180));
    painter.drawText(relX(137), relY(149), trUtf8("Бруто тежина"));
    painter.drawLine(relX(165), relY(145), relX(165), relY(180));
    painter.drawText(relX(167), relY(149), trUtf8("Запремнина(м3)"));

    painter.drawText(relX(12), relY(184), trUtf8("8. Забелешка и"));
    painter.drawText(relX(12), relY(188), trUtf8("   ограничувања на"));
    painter.drawText(relX(12), relY(192), trUtf8("   превозникот"));

    painter.drawLine(relX(10), relY(205), relX(200), relY(205));
    painter.drawText(relX(12), relY(209), trUtf8("9. Дополнителни"));
    painter.drawText(relX(12), relY(213), trUtf8("   инструкции при"));
    painter.drawText(relX(12), relY(217), trUtf8("   превоз на стоката"));

    painter.drawLine(relX(10), relY(230), relX(200), relY(230));
    painter.drawText(relX(12), relY(234), trUtf8("10. Робата ја превзема:"));
    painter.drawText(relX(12), relY(238), trUtf8("    Дата:"));
    painter.drawText(relX(12), relY(242), trUtf8("    Место:"));

    painter.drawLine(relX(10), relY(255), relX(200), relY(255));
    painter.drawText(relX(20), relY(260), trUtf8("Офис и КО"));
    painter.drawText(relX(12), relY(284), trUtf8("11. Потпис и ознака на"));
    painter.drawText(relX(12), relY(288), trUtf8("    испракачот"));
    
    painter.drawLine(relX(80), relY(255), relX(80), relY(290));
    painter.drawText(relX(90), relY(260), trUtf8("Офис и КО"));
    painter.drawText(relX(82), relY(284), trUtf8("12. Потпис и ознака на"));
    painter.drawText(relX(82), relY(288), trUtf8("    превозникот"));

    painter.drawLine(relX(150), relY(255), relX(150), relY(290));
    painter.drawText(relX(152), relY(284), trUtf8("13. Потпис и ознака на"));
    painter.drawText(relX(152), relY(288), trUtf8("    примачот"));
    
}